From e276ce3a64875af24c1a4eb7f592d5abb21b8ebc Mon Sep 17 00:00:00 2001 From: EricX-Zhao Date: Mon, 11 May 2026 10:28:33 +0300 Subject: [PATCH] Add ROS_ROOT configuration for cross-compilation Add ROS_ROOT argument to compose.yaml, update toolchain CMake to search in ROS_ROOT, and modify final stage of Dockerfiles to copy to ROS_ROOT instead of TARGET_SYSROOT. Also add support for ROS2 lyrical distro. --- cross_compile/compose.yaml | 2 + cross_compile/rk3588/rk3588.toolchain.cmake | 1 + cross_compile/ros2/jazzy/ros_jazzy.Dockerfile | 5 +- .../ros2/lyrical/ros_lyrical.Dockerfile | 96 ++++ cross_compile/ros2/lyrical/ros_lyrical.repos | 429 ++++++++++++++++++ .../ros2/rolling/ros_rolling.Dockerfile | 5 +- 6 files changed, 536 insertions(+), 2 deletions(-) create mode 100644 cross_compile/ros2/lyrical/ros_lyrical.Dockerfile create mode 100644 cross_compile/ros2/lyrical/ros_lyrical.repos diff --git a/cross_compile/compose.yaml b/cross_compile/compose.yaml index eaf92ec..c0d68fd 100644 --- a/cross_compile/compose.yaml +++ b/cross_compile/compose.yaml @@ -32,9 +32,11 @@ services: build: context: . dockerfile: ros2/${ROS_DISTRO}/ros_${ROS_DISTRO}.Dockerfile + # target: ros_builder args: ROS_DISTRO: ${ROS_DISTRO} PLATFORM: ${PLATFORM} + ROS_ROOT: /opt/ros/${ROS_DISTRO} CC_PLATFORM_IMAGE: ${PLATFORM}/cc-toolchain:latest VENDOR_PACKAGES_IMAGE: ${PLATFORM}/cc-vendor-packages:latest image: ${PLATFORM}/cc-ros-${ROS_DISTRO}:latest diff --git a/cross_compile/rk3588/rk3588.toolchain.cmake b/cross_compile/rk3588/rk3588.toolchain.cmake index 2acfec1..c9ba802 100644 --- a/cross_compile/rk3588/rk3588.toolchain.cmake +++ b/cross_compile/rk3588/rk3588.toolchain.cmake @@ -12,6 +12,7 @@ set(CMAKE_CXX_COMPILER ${SYSROOT}/bin/aarch64-none-linux-gnu-g++) list(APPEND CMAKE_FIND_ROOT_PATH $ENV{TARGET_SYSROOT} + $ENV{ROS_ROOT} ${CMAKE_INSTALL_PREFIX} ) diff --git a/cross_compile/ros2/jazzy/ros_jazzy.Dockerfile b/cross_compile/ros2/jazzy/ros_jazzy.Dockerfile index 751f8e5..72bdac3 100644 --- a/cross_compile/ros2/jazzy/ros_jazzy.Dockerfile +++ b/cross_compile/ros2/jazzy/ros_jazzy.Dockerfile @@ -92,4 +92,7 @@ RUN rm -rf ${TARGET_SYSROOT}/opt FROM ${CC_PLATFORM_IMAGE} AS final -COPY --from=rmw_zenoh_builder ${TARGET_SYSROOT} ${TARGET_SYSROOT} +ARG ROS_ROOT +ENV ROS_ROOT=${ROS_ROOT} +COPY --from=rmw_zenoh_builder ${TARGET_SYSROOT} ${ROS_ROOT} +WORKDIR /opt diff --git a/cross_compile/ros2/lyrical/ros_lyrical.Dockerfile b/cross_compile/ros2/lyrical/ros_lyrical.Dockerfile new file mode 100644 index 0000000..2a9299a --- /dev/null +++ b/cross_compile/ros2/lyrical/ros_lyrical.Dockerfile @@ -0,0 +1,96 @@ +ARG CC_PLATFORM_IMAGE +ARG VENDOR_PACKAGES_IMAGE + +FROM ${CC_PLATFORM_IMAGE} AS ros_src + +ARG ROS_DISTRO +WORKDIR /workspace +RUN mkdir -p /workspace/src +COPY ros2/${ROS_DISTRO}/ros_${ROS_DISTRO}.repos . +RUN vcs import --shallow --workers 4 --input ros_${ROS_DISTRO}.repos src +RUN echo "Build ros ${ROS_DISTRO}" + +FROM ${VENDOR_PACKAGES_IMAGE} AS vendor_images + +FROM ${CC_PLATFORM_IMAGE} AS ros_builder + +WORKDIR /workspace +COPY --from=ros_src /workspace /workspace +COPY --from=vendor_images ${TARGET_SYSROOT} ${TARGET_SYSROOT} +COPY ros2/ros_cpp /workspace/src/ros_cpp + +RUN touch src/ros2/geometry2/tf2_bullet/COLCON_IGNORE \ + && touch src/ros2/rosbag2/rosbag2_storage_sqlite3/COLCON_IGNORE \ + && touch src/ros-perception/image_transport_plugins/theora_image_transport/COLCON_IGNORE + +RUN MAKEFLAGS="-j6" colcon build \ + --executor parallel \ + --parallel-workers 6 \ + --install-base ${TARGET_SYSROOT} \ + --merge-install \ + --packages-up-to ros_cpp \ + --cmake-force-configure \ + --cmake-args \ + --no-warn-unused-cli \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_TOOLCHAIN_FILE=${CC_TOOLCHAIN_FILE} \ + -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ + -DBUILD_TESTING=OFF \ + -DTRACETOOLS_DISABLED=ON \ + -DCV_BRIDGE_DISABLE_PYTHON=ON + +# pybind11 python soabi issue +WORKDIR ${TARGET_SYSROOT}/lib/python3.10/site-packages/rclpy +RUN mv _rclpy_pybind11.cpython-310-x86_64-linux-gnu.so _rclpy_pybind11.cpython-310-aarch64-linux-gnu.so +WORKDIR ${TARGET_SYSROOT}/lib/python3.10/site-packages/rosbag2_py +RUN mv _transport.cpython-310-x86_64-linux-gnu.so _transport.cpython-310-aarch64-linux-gnu.so +RUN mv _info.cpython-310-x86_64-linux-gnu.so _info.cpython-310-aarch64-linux-gnu.so +RUN mv _compression_options.cpython-310-x86_64-linux-gnu.so _compression_options.cpython-310-aarch64-linux-gnu.so +RUN mv _storage.cpython-310-x86_64-linux-gnu.so _storage.cpython-310-aarch64-linux-gnu.so +RUN mv _reindexer.cpython-310-x86_64-linux-gnu.so _reindexer.cpython-310-aarch64-linux-gnu.so +RUN mv _writer.cpython-310-x86_64-linux-gnu.so _writer.cpython-310-aarch64-linux-gnu.so +RUN mv _message_definitions.cpython-310-x86_64-linux-gnu.so _message_definitions.cpython-310-aarch64-linux-gnu.so +RUN mv _reader.cpython-310-x86_64-linux-gnu.so _reader.cpython-310-aarch64-linux-gnu.so + +FROM ${CC_PLATFORM_IMAGE} AS rmw_zenoh_builder + +COPY --from=ros_builder ${TARGET_SYSROOT} ${TARGET_SYSROOT} + +# rust install +RUN curl https://sh.rustup.rs -sSf | sh -s -- -y +RUN . "$HOME/.cargo/env" \ + && rustup install 1.75.0 \ + && rustup default 1.75.0 \ + && rustup target add aarch64-unknown-linux-gnu + +RUN mkdir rmw_zenoh_ws/src -p \ + && cd rmw_zenoh_ws/src \ + && git clone --depth=1 -b rolling https://github.com/ros2/rmw_zenoh.git + +ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-none-linux-gnu-gcc + +RUN . "$HOME/.cargo/env" \ + && . ${TARGET_SYSROOT}/local_setup.sh \ + && colcon build \ + --install-base ${TARGET_SYSROOT} \ + --merge-install \ + --packages-up-to rmw_zenoh_cpp \ + --cmake-force-configure \ + --cmake-args \ + --no-warn-unused-cli \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_TOOLCHAIN_FILE=${CC_TOOLCHAIN_FILE} \ + -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ + -DBUILD_TESTING=OFF \ + -DZENOHC_CUSTOM_TARGET=aarch64-unknown-linux-gnu + +RUN cp -rf ${TARGET_SYSROOT}/opt/zenoh_cpp_vendor/include ${TARGET_SYSROOT} +RUN cp -rf ${TARGET_SYSROOT}/opt/zenoh_cpp_vendor/lib ${TARGET_SYSROOT} +RUN rm -rf ${TARGET_SYSROOT}/opt + +FROM ${CC_PLATFORM_IMAGE} AS final + +ARG ROS_ROOT +ENV ROS_ROOT=${ROS_ROOT} +COPY --from=rmw_zenoh_builder ${TARGET_SYSROOT} ${ROS_ROOT} +WORKDIR /opt diff --git a/cross_compile/ros2/lyrical/ros_lyrical.repos b/cross_compile/ros2/lyrical/ros_lyrical.repos new file mode 100644 index 0000000..8e2e580 --- /dev/null +++ b/cross_compile/ros2/lyrical/ros_lyrical.repos @@ -0,0 +1,429 @@ +repositories: + ament/ament_cmake: + type: git + url: https://github.com/ament/ament_cmake.git + version: lyrical + ament/ament_index: + type: git + url: https://github.com/ament/ament_index.git + version: lyrical + ament/ament_lint: + type: git + url: https://github.com/ament/ament_lint.git + version: lyrical + ament/ament_package: + type: git + url: https://github.com/ament/ament_package.git + version: lyrical + ament/google_benchmark_vendor: + type: git + url: https://github.com/ament/google_benchmark_vendor.git + version: lyrical + ament/googletest: + type: git + url: https://github.com/ament/googletest.git + version: lyrical + diagnostics: + type: git + url: https://github.com/ros/diagnostics.git + version: ros2 + eProsima/Fast-CDR: + type: git + url: https://github.com/eProsima/Fast-CDR.git + version: 2.3.x + eProsima/Fast-DDS: + type: git + url: https://github.com/eProsima/Fast-DDS.git + version: 3.6.x + eProsima/foonathan_memory_vendor: + type: git + url: https://github.com/eProsima/foonathan_memory_vendor.git + version: master + osrf/osrf_pycommon: + type: git + url: https://github.com/osrf/osrf_pycommon.git + version: master + osrf/osrf_testing_tools_cpp: + type: git + url: https://github.com/osrf/osrf_testing_tools_cpp.git + version: lyrical + ros-perception/pcl_msgs: + type: git + url: https://github.com/ros-perception/pcl_msgs.git + version: ros2 + ros-perception/image_common: + type: git + url: https://github.com/ros-perception/image_common.git + version: lyrical + ros-perception/laser_geometry: + type: git + url: https://github.com/ros-perception/laser_geometry.git + version: lyrical + ros-perception/perception_pcl: + type: git + url: https://github.com/ros-perception/perception_pcl.git + version: ros2 + ros-perception/point_cloud_transport: + type: git + url: https://github.com/ros-perception/point_cloud_transport.git + version: lyrical + ros-planning/navigation_msgs: + type: git + url: https://github.com/ros-planning/navigation_msgs.git + version: lyrical + ros-tooling/keyboard_handler: + type: git + url: https://github.com/ros-tooling/keyboard_handler.git + version: lyrical + ros-tooling/libstatistics_collector: + type: git + url: https://github.com/ros-tooling/libstatistics_collector.git + version: lyrical + ros-visualization/interactive_markers: + type: git + url: https://github.com/ros-visualization/interactive_markers.git + version: lyrical + ros-visualization/python_qt_binding: + type: git + url: https://github.com/ros-visualization/python_qt_binding.git + version: lyrical + ros-visualization/qt_gui_core: + type: git + url: https://github.com/ros-visualization/qt_gui_core.git + version: lyrical + ros-visualization/rqt: + type: git + url: https://github.com/ros-visualization/rqt.git + version: lyrical + ros-visualization/rqt_action: + type: git + url: https://github.com/ros-visualization/rqt_action.git + version: lyrical + ros-visualization/rqt_bag: + type: git + url: https://github.com/ros-visualization/rqt_bag.git + version: lyrical + ros-visualization/rqt_console: + type: git + url: https://github.com/ros-visualization/rqt_console.git + version: lyrical + ros-visualization/rqt_graph: + type: git + url: https://github.com/ros-visualization/rqt_graph.git + version: lyrical + ros-visualization/rqt_msg: + type: git + url: https://github.com/ros-visualization/rqt_msg.git + version: lyrical + ros-visualization/rqt_plot: + type: git + url: https://github.com/ros-visualization/rqt_plot.git + version: lyrical + ros-visualization/rqt_publisher: + type: git + url: https://github.com/ros-visualization/rqt_publisher.git + version: lyrical + ros-visualization/rqt_py_console: + type: git + url: https://github.com/ros-visualization/rqt_py_console.git + version: lyrical + ros-visualization/rqt_reconfigure: + type: git + url: https://github.com/ros-visualization/rqt_reconfigure.git + version: lyrical + ros-visualization/rqt_service_caller: + type: git + url: https://github.com/ros-visualization/rqt_service_caller.git + version: lyrical + ros-visualization/rqt_shell: + type: git + url: https://github.com/ros-visualization/rqt_shell.git + version: lyrical + ros-visualization/rqt_srv: + type: git + url: https://github.com/ros-visualization/rqt_srv.git + version: lyrical + ros-visualization/rqt_topic: + type: git + url: https://github.com/ros-visualization/rqt_topic.git + version: lyrical + ros-visualization/tango_icons_vendor: + type: git + url: https://github.com/ros-visualization/tango_icons_vendor.git + version: lyrical + ros/class_loader: + type: git + url: https://github.com/ros/class_loader.git + version: lyrical + ros/kdl_parser: + type: git + url: https://github.com/ros/kdl_parser.git + version: lyrical + ros/pluginlib: + type: git + url: https://github.com/ros/pluginlib.git + version: lyrical + ros/resource_retriever: + type: git + url: https://github.com/ros/resource_retriever.git + version: lyrical + ros/robot_state_publisher: + type: git + url: https://github.com/ros/robot_state_publisher.git + version: lyrical + ros/ros_environment: + type: git + url: https://github.com/ros/ros_environment.git + version: lyrical + ros/ros_tutorials: + type: git + url: https://github.com/ros/ros_tutorials.git + version: lyrical + ros/urdfdom: + type: git + url: https://github.com/ros/urdfdom.git + version: lyrical + ros/urdfdom_headers: + type: git + url: https://github.com/ros/urdfdom_headers.git + version: lyrical + ros/eigen_stl_containers: + type: git + url: https://github.com/ros/eigen_stl_containers.git + version: ros2 + ros/angles: + type: git + url: https://github.com/ros/angles.git + version: ros2 + ros-geographic-info: + type: git + url: https://github.com/ros-geographic-info/geographic_info.git + version: ros2 + ros2/ament_cmake_ros: + type: git + url: https://github.com/ros2/ament_cmake_ros.git + version: lyrical + ros2/common_interfaces: + type: git + url: https://github.com/ros2/common_interfaces.git + version: lyrical + ros2/demos: + type: git + url: https://github.com/ros2/demos.git + version: lyrical + ros2/eigen3_cmake_module: + type: git + url: https://github.com/ros2/eigen3_cmake_module.git + version: lyrical + ros2/example_interfaces: + type: git + url: https://github.com/ros2/example_interfaces.git + version: lyrical + ros2/examples: + type: git + url: https://github.com/ros2/examples.git + version: lyrical + ros2/geometry2: + type: git + url: https://github.com/ros2/geometry2.git + version: lyrical + ros2/launch: + type: git + url: https://github.com/ros2/launch.git + version: lyrical + ros2/launch_ros: + type: git + url: https://github.com/ros2/launch_ros.git + version: lyrical + ros2/message_filters: + type: git + url: https://github.com/ros2/message_filters.git + version: lyrical + ros2/performance_test_fixture: + type: git + url: https://github.com/ros2/performance_test_fixture.git + version: lyrical + ros2/rcl: + type: git + url: https://github.com/ros2/rcl.git + version: lyrical + ros2/rcl_interfaces: + type: git + url: https://github.com/ros2/rcl_interfaces.git + version: lyrical + ros2/rcl_logging: + type: git + url: https://github.com/ros2/rcl_logging.git + version: lyrical + ros2/rclcpp: + type: git + url: https://github.com/ros2/rclcpp.git + version: lyrical + ros2/rclpy: + type: git + url: https://github.com/ros2/rclpy.git + version: lyrical + ros2/rcpputils: + type: git + url: https://github.com/ros2/rcpputils.git + version: lyrical + ros2/rcutils: + type: git + url: https://github.com/ros2/rcutils.git + version: lyrical + ros2/realtime_support: + type: git + url: https://github.com/ros2/realtime_support.git + version: lyrical + ros2/rmw: + type: git + url: https://github.com/ros2/rmw.git + version: lyrical + ros2/rmw_connextdds: + type: git + url: https://github.com/ros2/rmw_connextdds.git + version: lyrical + ros2/rmw_cyclonedds: + type: git + url: https://github.com/ros2/rmw_cyclonedds.git + version: lyrical + ros2/rmw_dds_common: + type: git + url: https://github.com/ros2/rmw_dds_common.git + version: lyrical + ros2/rmw_fastrtps: + type: git + url: https://github.com/ros2/rmw_fastrtps.git + version: lyrical + ros2/rmw_implementation: + type: git + url: https://github.com/ros2/rmw_implementation.git + version: lyrical + ros2/ros2_tracing: + type: git + url: https://github.com/ros2/ros2_tracing.git + version: lyrical + ros2/ros2cli: + type: git + url: https://github.com/ros2/ros2cli.git + version: lyrical + ros2/ros2cli_common_extensions: + type: git + url: https://github.com/ros2/ros2cli_common_extensions.git + version: lyrical + ros2/ros_testing: + type: git + url: https://github.com/ros2/ros_testing.git + version: lyrical + ros2/rosbag2: + type: git + url: https://github.com/ros2/rosbag2.git + version: lyrical + ros2/rosidl: + type: git + url: https://github.com/ros2/rosidl.git + version: lyrical + ros2/rosidl_core: + type: git + url: https://github.com/ros2/rosidl_core.git + version: lyrical + ros2/rosidl_dds: + type: git + url: https://github.com/ros2/rosidl_dds.git + version: lyrical + ros2/rosidl_defaults: + type: git + url: https://github.com/ros2/rosidl_defaults.git + version: lyrical + ros2/rosidl_dynamic_typesupport: + type: git + url: https://github.com/ros2/rosidl_dynamic_typesupport.git + version: lyrical + ros2/rosidl_dynamic_typesupport_fastrtps: + type: git + url: https://github.com/ros2/rosidl_dynamic_typesupport_fastrtps.git + version: lyrical + ros2/rosidl_python: + type: git + url: https://github.com/ros2/rosidl_python.git + version: lyrical + ros2/rosidl_runtime_py: + type: git + url: https://github.com/ros2/rosidl_runtime_py.git + version: lyrical + ros2/rosidl_typesupport: + type: git + url: https://github.com/ros2/rosidl_typesupport.git + version: lyrical + ros2/rosidl_typesupport_fastrtps: + type: git + url: https://github.com/ros2/rosidl_typesupport_fastrtps.git + version: lyrical + ros2/rpyutils: + type: git + url: https://github.com/ros2/rpyutils.git + version: lyrical + ros2/rviz: + type: git + url: https://github.com/ros2/rviz.git + version: lyrical + ros2/sros2: + type: git + url: https://github.com/ros2/sros2.git + version: lyrical + ros2/system_tests: + type: git + url: https://github.com/ros2/system_tests.git + version: lyrical + ros2/test_interface_files: + type: git + url: https://github.com/ros2/test_interface_files.git + version: lyrical + ros2/tlsf: + type: git + url: https://github.com/ros2/tlsf.git + version: lyrical + ros2/unique_identifier_msgs: + type: git + url: https://github.com/ros2/unique_identifier_msgs.git + version: lyrical + ros2/urdf: + type: git + url: https://github.com/ros2/urdf.git + version: lyrical + vision_msgs: + type: git + url: https://github.com/ros-perception/vision_msgs.git + version: ros2 + ros2/console_bridge_vendor: + type: git + url: https://github.com/ros2/console_bridge_vendor.git + version: lyrical + ros2/libyaml_vendor: + type: git + url: https://github.com/ros2/libyaml_vendor.git + version: lyrical + ros2/spdlog_vendor: + type: git + url: https://github.com/ros2/spdlog_vendor.git + version: lyrical + ros2/yaml_cpp_vendor: + type: git + url: https://github.com/ros2/yaml_cpp_vendor.git + version: lyrical + ffmpeg_image_transport_msgs: + type: git + url: https://github.com/ros-misc-utilities/ffmpeg_image_transport_msgs.git + version: rolling + ros-perception/image_transport_plugins: + type: git + url: https://github.com/ros-perception/image_transport_plugins.git + version: rolling + ros2/python_cmake_module: + type: git + url: https://github.com/ros2/python_cmake_module.git + version: rolling + vision_opencv: + type: git + url: https://github.com/ros-perception/vision_opencv.git + version: rolling \ No newline at end of file diff --git a/cross_compile/ros2/rolling/ros_rolling.Dockerfile b/cross_compile/ros2/rolling/ros_rolling.Dockerfile index 62a0f42..92af08c 100644 --- a/cross_compile/ros2/rolling/ros_rolling.Dockerfile +++ b/cross_compile/ros2/rolling/ros_rolling.Dockerfile @@ -91,4 +91,7 @@ RUN rm -rf ${TARGET_SYSROOT}/opt FROM ${CC_PLATFORM_IMAGE} AS final -COPY --from=rmw_zenoh_builder ${TARGET_SYSROOT} ${TARGET_SYSROOT} +ARG ROS_ROOT +ENV ROS_ROOT=${ROS_ROOT} +COPY --from=rmw_zenoh_builder ${TARGET_SYSROOT} ${ROS_ROOT} +WORKDIR /opt