Dockerfile.NavStack 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. # Copyright (c) Contributors to the Open 3D Engine Project.
  2. # For complete copyright and license terms please see the LICENSE at the root of this distribution.
  3. #
  4. # SPDX-License-Identifier: Apache-2.0 OR MIT
  5. #
  6. ARG ROS_VERSION=humble
  7. ARG UBUNTU_VERSION=jammy
  8. FROM ros:${ROS_VERSION}-ros-base-${UBUNTU_VERSION}
  9. ENV WORKSPACE=/data/workspace
  10. WORKDIR $WORKSPACE
  11. # ROSConDemo Variables
  12. ARG ROSCON_DEMO_REPO=https://github.com/o3de/ROSConDemo.git
  13. ARG ROSCON_DEMO_BRANCH=main
  14. ARG ROSCON_DEMO_COMMIT=HEAD
  15. ENV ROSCON_DEMO_ROOT=$WORKSPACE/ROSConDemo
  16. ENV ROSCON_DEMO_NAV_ROOT=$WORKSPACE/kraken_nav
  17. ENV LANG=en_US.UTF-8
  18. # Setup time zone and locale data (necessary for SSL and HTTPS packages)
  19. RUN apt-get update \
  20. && DEBIAN_FRONTEND="noninteractive" apt-get -y install tzdata locales keyboard-configuration curl \
  21. && sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen \
  22. && dpkg-reconfigure --frontend=noninteractive locales \
  23. && update-locale LANG=en_US.UTF-8 \
  24. && sh -c 'echo "deb [arch=amd64,arm64] http://repo.ros2.org/ubuntu/main `lsb_release -cs` main" > /etc/apt/sources.list.d/ros2-latest.list' \
  25. && curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add - \
  26. && rm -rf /var/lib/apt/lists/*
  27. # Install the required ubuntu packages
  28. RUN apt-get update \
  29. && apt-get install -y \
  30. python3 \
  31. python3-pip \
  32. git \
  33. git-lfs \
  34. software-properties-common \
  35. ros-${ROS_DISTRO}-ackermann-msgs \
  36. ros-${ROS_DISTRO}-control-toolbox \
  37. ros-${ROS_DISTRO}-gazebo-msgs \
  38. ros-${ROS_DISTRO}-joy \
  39. ros-${ROS_DISTRO}-navigation2 \
  40. ros-${ROS_DISTRO}-rviz2 \
  41. ros-${ROS_DISTRO}-tf2-ros \
  42. ros-${ROS_DISTRO}-urdfdom \
  43. ros-${ROS_DISTRO}-vision-msgs \
  44. ros-${ROS_DISTRO}-cyclonedds \
  45. ros-${ROS_DISTRO}-rmw-cyclonedds-cpp \
  46. ros-${ROS_DISTRO}-slam-toolbox \
  47. ros-${ROS_DISTRO}-nav2-bringup \
  48. ros-${ROS_DISTRO}-pointcloud-to-laserscan \
  49. ros-${ROS_DISTRO}-teleop-twist-keyboard \
  50. ros-${ROS_DISTRO}-topic-tools \
  51. python3-colcon-common-extensions \
  52. && rm -rf /var/lib/apt/lists/* \
  53. && pip install python-statemachine
  54. ENV RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
  55. # Clone and build the navstack project
  56. RUN . /opt/ros/${ROS_DISTRO}/setup.sh \
  57. ############################################################### \
  58. # Clone the ROSConDemo \
  59. ############################################################### \
  60. && git clone --single-branch -b $ROSCON_DEMO_BRANCH $ROSCON_DEMO_REPO $ROSCON_DEMO_ROOT \
  61. && git -C $ROSCON_DEMO_ROOT lfs install \
  62. && git -C $ROSCON_DEMO_ROOT lfs pull \
  63. && git -C $ROSCON_DEMO_ROOT reset --hard $ROSCON_DEMO_COMMIT \
  64. && mv $ROSCON_DEMO_ROOT/kraken_nav $ROSCON_DEMO_NAV_ROOT \
  65. && rm -rf $ROSCON_DEMO_ROOT
  66. # Build the navigation stack
  67. RUN . /opt/ros/${ROS_DISTRO}/setup.sh \
  68. && cd $ROSCON_DEMO_NAV_ROOT \
  69. && colcon build --symlink-install
  70. # Add the appropriate ros2 environment setup script to the system startup
  71. RUN echo "[Unit]" > /etc/systemd/system/setup_ros.service \
  72. && echo "After=network.target" >> /etc/systemd/system/setup_ros.service \
  73. && echo "" >> /etc/systemd/system/setup_ros.service \
  74. && echo "[Service]" >> /etc/systemd/system/setup_ros.service \
  75. && if [ "${ROS_DISTRO}" = "iron" ]; then \
  76. echo "ExecStart=/opt/ros/iron/setup.bash" >> /etc/systemd/system/setup_ros.service; \
  77. elif [ "${ROS_DISTRO}" = "humble" ]; then \
  78. echo "ExecStart=/opt/ros/humble/setup.bash" >> /etc/systemd/system/setup_ros.service; \
  79. elif [ "${ROS_DISTRO}" = "galactic" ]; then \
  80. echo "ExecStart=/opt/ros/galactic/setup.bash" >> /etc/systemd/system/setup_ros.service; \
  81. fi \
  82. && echo "" >> /etc/systemd/system/setup_ros.service \
  83. && echo "[Install]" >> /etc/systemd/system/setup_ros.service \
  84. && echo "WantedBy=default.target" >> /etc/systemd/system/setup_ros.service \
  85. && echo "" >> /etc/systemd/system/setup_ros.service
  86. ENV NVIDIA_VISIBLE_DEVICES all
  87. ENV NVIDIA_DRIVER_CAPABILITIES all