From bba6830e6a0b1c9a991bb46c25c504e7a9534640 Mon Sep 17 00:00:00 2001 From: Erik Holum Date: Mon, 21 Oct 2024 09:48:00 -0400 Subject: [PATCH 1/4] Update MoveIt2 build for new base image (issue #198) --- moveit2/Dockerfile | 40 +++++++++++++++++----------------------- moveit2/README.md | 11 +++++------ 2 files changed, 22 insertions(+), 29 deletions(-) diff --git a/moveit2/Dockerfile b/moveit2/Dockerfile index d5e095f..4545601 100644 --- a/moveit2/Dockerfile +++ b/moveit2/Dockerfile @@ -24,6 +24,8 @@ ARG SPACE_ROS_IMAGE=osrf/space-ros:latest FROM ${SPACE_ROS_IMAGE} +SHELL ["bash", "-c"] + # Define arguments used in the metadata definition ARG VCS_REF ARG VERSION="preview" @@ -41,12 +43,9 @@ LABEL org.label-schema.vcs-ref=${VCS_REF} # Disable prompting during package installation ARG DEBIAN_FRONTEND=noninteractive -# Clone all space-ros sources -RUN mkdir ${SPACEROS_DIR}/src \ - && vcs import ${SPACEROS_DIR}/src < ${SPACEROS_DIR}/exact.repos - # Define key locations -ENV MOVEIT2_DIR=${HOME_DIR}/moveit2 +ENV MOVEIT2_DIR=${HOME}/moveit2 +ENV SPACEROS_WS=${HOME}/spaceros # Make sure the latest versions of packages are installed # Using Docker BuildKit cache mounts for /var/cache/apt and /var/lib/apt ensures that @@ -57,7 +56,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ --mount=type=cache,target=/var/lib/apt,sharing=locked \ sudo apt-get dist-upgrade -y -RUN rosdep update +RUN sudo rosdep init && rosdep update # Install the various build and test tools RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ @@ -92,15 +91,14 @@ RUN python3 -m pip install -U \ pytest-rerunfailures \ pytest -# Get the MoveIt2 source code -WORKDIR ${HOME_DIR} -RUN sudo git clone https://github.com/ros-planning/moveit2.git -b ${ROS_DISTRO} moveit2/src -RUN cd ${MOVEIT2_DIR}/src \ - && sudo git clone https://github.com/ros-planning/moveit2_tutorials.git -b ${ROS_DISTRO} +# Clone all space-ros sources +RUN mkdir -p ${SPACEROS_WS}/src \ + && vcs import ${SPACEROS_WS}/src < ${SPACEROS_DIR}/scripts/spaceros.repos -# Update the ownership of the source files (had to use sudo above to work around -# a possible inherited 'insteadof' from the host that forces use of ssh -RUN sudo chown -R ${USERNAME}:${USERNAME} ${MOVEIT2_DIR} +# Get the MoveIt2 source code +WORKDIR ${MOVEIT2_DIR}/src +RUN git clone https://github.com/ros-planning/moveit2.git -b ${ROS_DISTRO} +RUN git clone https://github.com/ros-planning/moveit2_tutorials.git -b ${ROS_DISTRO} # Get rosinstall_generator RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ @@ -113,7 +111,7 @@ COPY --chown=${USERNAME}:${USERNAME} excluded-pkgs.txt /tmp/ RUN rosinstall_generator \ --rosdistro ${ROS_DISTRO} \ --deps \ - --exclude-path ${SPACEROS_DIR}/src \ + --exclude-path ${SPACEROS_WS}/ \ --exclude $(cat /tmp/excluded-pkgs.txt) -- \ -- $(cat /tmp/moveit2-pkgs.txt) \ > /tmp/moveit2_generated_pkgs.repos @@ -121,25 +119,21 @@ RUN rosinstall_generator \ # Get the repositories required by MoveIt2, but not included in Space ROS WORKDIR ${MOVEIT2_DIR} RUN vcs import src < /tmp/moveit2_generated_pkgs.repos -COPY --chown=${USERNAME}:${USERNAME} moveit2_tutorials.repos /tmp/ +COPY moveit2_tutorials.repos /tmp/ RUN vcs import src < /tmp/moveit2_tutorials.repos -# Update the ownership of the source files (had to use sudo above to work around -# a possible inherited 'insteadof' from the host that forces use of ssh -RUN sudo chown -R ${USERNAME}:${USERNAME} ${MOVEIT2_DIR} - # Install system dependencies RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ --mount=type=cache,target=/var/lib/apt,sharing=locked \ - /bin/bash -c 'source ${SPACEROS_DIR}/install/setup.bash' \ - && rosdep install --from-paths src --ignore-src --rosdistro ${ROS_DISTRO} -r -y --skip-keys "console_bridge generate_parameter_library fastcdr fastrtps rti-connext-dds-5.3.1 urdfdom_headers rmw_connextdds ros_testing rmw_connextdds rmw_fastrtps_cpp rmw_fastrtps_dynamic_cpp composition demo_nodes_py lifecycle rosidl_typesupport_fastrtps_cpp rosidl_typesupport_fastrtps_c ikos diagnostic_aggregator diagnostic_updater joy qt_gui rqt_gui rqt_gui_py" + /bin/bash -c 'source ${SPACEROS_DIR}/setup.bash' \ + && rosdep install --from-paths src --ignore-src --rosdistro ${ROS_DISTRO} -r -y --skip-keys "console_bridge generate_parameter_library fastcdr fastrtps rti-connext-dds-5.3.1 urdfdom_headers rmw_connextdds ros_testing rmw_connextdds rmw_fastrtps_cpp rmw_fastrtps_dynamic_cpp composition demo_nodes_py lifecycle rosidl_typesupport_fastrtps_cpp rosidl_typesupport_fastrtps_c ikos diagnostic_aggregator diagnostic_updater joy qt_gui rqt_gui rqt_gui_py" # Apply a patch to octomap_msgs to work around a build issue COPY --chown=${USERNAME}:${USERNAME} octomap_fix.diff ./src/octomap_msgs RUN cd src/octomap_msgs && git apply octomap_fix.diff # Build MoveIt2 -RUN /bin/bash -c 'source ${SPACEROS_DIR}/install/setup.bash \ +RUN /bin/bash -c 'source ${SPACEROS_DIR}/setup.bash \ && colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON --event-handlers desktop_notification- status-' # Add a couple sample GUI apps for testing diff --git a/moveit2/README.md b/moveit2/README.md index 99093ec..efdc4e1 100644 --- a/moveit2/README.md +++ b/moveit2/README.md @@ -16,7 +16,7 @@ If building locally, the underlying base image can be set in the [build script]( ```bash # Use a locally built image as the base -SPACE_ROS_IMAGE="space-ros:main" ./build.sh +SPACE_ROS_IMAGE="space-ros:latest" ./build.sh ``` The build process will take about 30 minutes, depending on the host computer. @@ -31,11 +31,10 @@ docker image list The output will look something like this: -``` -REPOSITORY TAG IMAGE ID CREATED SIZE -openrobotics/moveit2 latest 6edb2edc9643 10 hours ago 15.5GB -openrobotics/spaceros latest 629b13cf7b74 12 hours ago 7.8GB -nvidia/cudagl 11.4.1-devel-ubuntu20.04 336416dfcbba 1 week ago 5.35GB +```docker image list +REPOSITORY TAG IMAGE ID CREATED SIZE +openrobotics/moveit2 latest 98cd8f08f954 About a minute ago 8.2GB +osrf/space-ros latest cf10cd2cb82c 27 hours ago 1.05GB ``` The new image is named **openrobotics/moveit2:latest**. From f5aab6416aa4000fcd7585c83e80baa671b4a8d2 Mon Sep 17 00:00:00 2001 From: Erik Holum Date: Mon, 21 Oct 2024 09:48:11 -0400 Subject: [PATCH 2/4] Update the space robots demo for new base image (issue #198) --- space_robots/Dockerfile | 11 ++++------- space_robots/README.md | 7 ++----- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/space_robots/Dockerfile b/space_robots/Dockerfile index 562b8a5..90a17da 100644 --- a/space_robots/Dockerfile +++ b/space_robots/Dockerfile @@ -36,7 +36,7 @@ LABEL org.label-schema.vcs-url="https://github.com/space-ros/docker" LABEL org.label-schema.vcs-ref=${VCS_REF} # Define a few key variables -ENV DEMO_DIR=${HOME_DIR}/demos_ws +ENV DEMO_DIR=${HOME}/demos_ws ENV IGNITION_VERSION fortress ENV GZ_VERSION fortress @@ -84,22 +84,19 @@ RUN cd mongo-cxx-driver-r3.6.7/build && cmake .. -DCMAKE_BUILD_TYPE=Release -DCM # Get the source for the dependencies # RUN vcs import src < /tmp/demo_generated_pkgs.repos COPY --chown=${USERNAME}:${USERNAME} demo_manual_pkgs.repos /tmp/ -RUN vcs import src < /tmp/demo_manual_pkgs.repos && /bin/bash -c 'source "${SPACEROS_DIR}/install/setup.bash"' +RUN vcs import src < /tmp/demo_manual_pkgs.repos && /bin/bash -c 'source "${SPACEROS_DIR}/setup.bash"' RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ --mount=type=cache,target=/var/lib/apt,sharing=locked \ sudo apt-get update -y \ -&& /bin/bash -c 'source "${SPACEROS_DIR}/install/setup.bash"' \ +&& /bin/bash -c 'source "${SPACEROS_DIR}/setup.bash"' \ && /bin/bash -c 'source "${MOVEIT2_DIR}/install/setup.bash"' \ && rosdep install --from-paths src --ignore-src -r -y --rosdistro ${ROS_DISTRO} # Build the demo -RUN /bin/bash -c 'source ${SPACEROS_DIR}/install/setup.bash && source ${MOVEIT2_DIR}/install/setup.bash \ +RUN /bin/bash -c 'source ${SPACEROS_DIR}/setup.bash && source ${MOVEIT2_DIR}/install/setup.bash \ && colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release' -# Add the user to the render group so that the user can access /dev/dri/renderD128 -RUN sudo usermod -aG render $USERNAME - # Setup the entrypoint COPY ./entrypoint.sh / ENTRYPOINT ["/entrypoint.sh"] diff --git a/space_robots/README.md b/space_robots/README.md index 44c380d..4d17ab9 100644 --- a/space_robots/README.md +++ b/space_robots/README.md @@ -37,6 +37,7 @@ Depending on the host computer, you might need to remove the ```--gpus all``` fl ## Running the Demos ### Curiosity Mars rover demo + Launch the demo: ```bash ros2 launch mars_rover mars_rover.launch.py @@ -57,11 +58,7 @@ docker exec -it bash Make sure packages are sourced: ```bash -source ${SPACEROS_DIR}/install/setup.bash -``` - -```bash -source ~/demos_ws/install/setup.bash +source ${DEMO_DIR}/install/setup.bash ``` #### Available Commands From 45fd06c6e9e8f813f72eca0cf7302ebca4834c27 Mon Sep 17 00:00:00 2001 From: Erik Holum Date: Tue, 22 Oct 2024 11:46:34 -0400 Subject: [PATCH 3/4] Fix the navigation2 build (issue #198) --- navigation2/Dockerfile | 21 +++++++++++++++------ navigation2/README.md | 6 +++--- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/navigation2/Dockerfile b/navigation2/Dockerfile index 6c6f2d7..0f059f4 100644 --- a/navigation2/Dockerfile +++ b/navigation2/Dockerfile @@ -43,8 +43,17 @@ ARG DEBIAN_FRONTEND=noninteractive SHELL ["/bin/bash", "-c"] +# Install required dependencies +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + sudo apt update && \ + sudo apt install -y \ + python3-rosdep \ + python3-vcstool +RUN sudo rosdep init && rosdep update + # Define workspace locations -ENV NAVIGATION2_WS=${HOME_DIR}/nav2_ws +ENV NAVIGATION2_WS=${HOME}/nav2_ws RUN mkdir -p ${NAVIGATION2_WS}/src @@ -56,19 +65,19 @@ RUN vcs import --shallow src < navigation2.repos COPY --chown=spaceros-user:spaceros-user src/ src RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ - --mount=type=cache,target=/var/lib/apt,sharing=locked \ - source ${SPACEROS_DIR}/install/setup.bash && \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + source ${SPACEROS_DIR}/setup.bash && \ sudo apt update && \ rosdep install -i --from-path src --skip-keys $(cat excluded-pkgs.txt) -y -RUN source ${SPACEROS_DIR}/install/setup.bash && \ +RUN source ${SPACEROS_DIR}/setup.bash && \ colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON --no-warn-unused-cli RUN rm -rf src build log -# Install rviz2 to send goals to Nav2. +# Install rviz2 to send goals to Nav2. # TODO(xfiderek): Remove rviz2 and humble-nav2 froms this image RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ - --mount=type=cache,target=/var/lib/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ sudo apt update && \ sudo apt install -y ros-humble-rviz2 ros-humble-nav2-bringup diff --git a/navigation2/README.md b/navigation2/README.md index 1b8bb04..d9a2a65 100644 --- a/navigation2/README.md +++ b/navigation2/README.md @@ -33,9 +33,9 @@ docker image list The output will look something like this: ``` -REPOSITORY TAG IMAGE ID CREATED SIZE -osrf/space_nav2 latest 6edb2edc9643 10 hours ago 15.5GB -osrf/space-ros latest 629b13cf7b74 12 hours ago 7.8GB +REPOSITORY TAG IMAGE ID CREATED SIZE +osrf/space_nav2 latest 7016292fba1c 32 minutes ago 3.65GB +osrf/space-ros latest cf10cd2cb82c 4 days ago 1.05GB ``` The new image is named **osrf/space_nav2:latest**. From 207036ca47aef31ffab2a6da5c5598e4a0e950e9 Mon Sep 17 00:00:00 2001 From: Erik Holum Date: Tue, 22 Oct 2024 11:46:56 -0400 Subject: [PATCH 4/4] Fix the nav2_demo build (issue #198) --- nav2_demo/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nav2_demo/Dockerfile b/nav2_demo/Dockerfile index e40b9d8..2b55d7a 100644 --- a/nav2_demo/Dockerfile +++ b/nav2_demo/Dockerfile @@ -39,8 +39,8 @@ LABEL org.label-schema.vcs-ref=${VCS_REF} ARG DEBIAN_FRONTEND=noninteractive # Define workspace locations -ENV NAVIGATION2_WS=${HOME_DIR}/nav2_ws -ENV NAV2_DEPS_WS=${HOME_DIR}/nav2_deps_ws +ENV NAVIGATION2_WS=${HOME}/nav2_ws +ENV NAV2_DEPS_WS=${HOME}/nav2_deps_ws # Setup mars_rover demo # Install map file for localization