diff --git a/Dockerfile b/Dockerfile index 09cd696..74233e8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,40 +18,19 @@ RUN ./patches/apply_patches.sh # NOTE: There should be a check in your CI that this file is up to date. # Something like: # ./scripts/freeze-rosdep.sh && git diff --exit-code rosdep-packages.txt -# COPY rosdep-packages.txt /tmp/rosdep-packages.txt +COPY rosdep-packages.txt /tmp/rosdep-packages.txt # The --mount=type=cache option caches the apt packages with buildkit # The id-apt-cache-${TARGETARCH} option allows for separate caches for different architectures # this enables parallel builds for different architectures without cache conflicts -# RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=apt-cache-${TARGETARCH} \ -# rm -f /etc/apt/apt.conf.d/docker-clean \ -# && apt-get update \ -# && xargs -r -a /tmp/rosdep-packages.txt apt-get install -y --no-install-recommends \ -# && rm -rf /var/lib/apt/lists/* - -# Make sure the base image is completely up to date -# ros:jazzy ships /etc/apt/apt.conf.d/docker-clean which purges downloaded .debs; -# remove it so the --mount=type=cache on /var/cache/apt actually retains archives. RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=apt-cache-${TARGETARCH} \ rm -f /etc/apt/apt.conf.d/docker-clean \ && apt-get update \ - && apt-get upgrade -y \ + && xargs -r -a /tmp/rosdep-packages.txt apt-get install -y --no-install-recommends \ && rm -rf /var/lib/apt/lists/* -# iproute2 provides `ip`, used by agv_pro_hardware/AgvProHardwareInterface and -# agv_pro_bringup's can_power_on.py to bring up the wheel CAN interface at runtime. -# Not a ROS package so rosdep won't pull it in -- install it explicitly. -RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=apt-cache-${TARGETARCH} \ - rm -f /etc/apt/apt.conf.d/docker-clean \ - && apt-get update \ - && apt-get install -y --no-install-recommends iproute2 \ - && rm -rf /var/lib/apt/lists/* - - # Install dependencies with rosdep # This will catch anything that wasn't installed via .deb's from the frozen rosdep manifest. -RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=apt-cache-${TARGETARCH} \ - rm -f /etc/apt/apt.conf.d/docker-clean && \ - apt-get update && \ +RUN apt-get update && \ rosdep update && \ rosdep install --from-paths src --ignore-src -r -y && \ rm -rf /var/lib/apt/lists/* @@ -59,7 +38,9 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=apt-cache-${TARGE # Build the workspace with symlink install # livox_sdk is now an ament_cmake package built by colcon (no manual /usr/local install needed). RUN . /opt/ros/jazzy/setup.sh && \ - colcon build --symlink-install + colcon build --symlink-install \ + --cmake-args -DROS_EDITION=ROS2 -DDISTRO_ROS=jazzy + # Source the overlay on container startup RUN echo "source /opt/ros/jazzy/setup.bash" >> /root/.bashrc && \ echo "source /ros2_ws/install/setup.bash" >> /root/.bashrc diff --git a/patches/livox_sdk.patch b/patches/livox_sdk.patch index 08b9475..d4ce445 100644 --- a/patches/livox_sdk.patch +++ b/patches/livox_sdk.patch @@ -38,3 +38,28 @@ index 15e960d..aa9e08a 100644 + PUBLIC_HEADER DESTINATION /usr/local/include + ARCHIVE DESTINATION /usr/local/lib + LIBRARY DESTINATION /usr/local/lib) +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 05f84c5..4fb6f31 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,7 +1,9 @@ +-cmake_minimum_required(VERSION 3.0) ++cmake_minimum_required(VERSION 3.5) + + project(livox_sdk2) + ++find_package(ament_cmake REQUIRED) ++ + set(CMAKE_CXX_STANDARD 11) + + message(STATUS "main project dir: " ${PROJECT_SOURCE_DIR}) +@@ -18,3 +20,9 @@ endif(UNIX) + + add_subdirectory(sdk_core) + add_subdirectory(samples) ++ ++# Export the installed headers/libraries so ament packages (e.g. livox_ros_driver2) ++# find the SDK from the colcon install space via CMAKE_PREFIX_PATH. ++ament_export_include_directories(include) ++ament_export_libraries(livox_lidar_sdk_shared) ++ament_package()