Skip to content

Instantly share code, notes, and snippets.

@brianlmerritt
Last active April 7, 2024 09:21
Show Gist options
  • Save brianlmerritt/68e11e51d3ad219ad19a94f0916e2bc7 to your computer and use it in GitHub Desktop.
Save brianlmerritt/68e11e51d3ad219ad19a94f0916e2bc7 to your computer and use it in GitHub Desktop.
Install ROS 2 Humble Desktop on Jetson Orin Nano JetPack 6 with Cartographer and Navigation and Cuda
# Install ros-humber-desktop plus goodies from jetson-containers
git clone https://github.com/dusty-nv/jetson-containers
cd jetson containers
# Build pytorch, transformers, opencv, realsense, and the base ros:humble-desktop environment
# Note on first build, remove the --skip-tests=all tag and make sure it all comes together
./build.sh --name=your_container_tag --skip-tests=all pytorch transformers opencv realsense ros:humble-desktop
# Once this is done, build the Dockerfile - you can use ./run.sh your_container_tag:l4t-r36.2.0 to test it first if you want
# I am doing it from the agilex weston rs for my agilex limo
# Well done - you now have a ros-humble dev environment (exluding gazebo, but with cuda enabled pytorch, opencv, transformers and
# cartographer and navigator2 installed, ready for your workspace
#Jetson Containers tags the output the l4t version - check yours is the right one
FROM your_container_tag:l4t-r36.2.0
ENV DEBIAN_FRONTEND=noninteractive
ARG UID=1000
ARG GID=1000
# Some of this is from https://github.com/atinfinity/l4t-ros2-docker
# add new sudo user
ENV USERNAME jetson
ENV HOME /home/$USERNAME
RUN useradd -m $USERNAME && \
echo "$USERNAME:$USERNAME" | chpasswd && \
usermod --shell /bin/bash $USERNAME && \
usermod -aG sudo $USERNAME && \
echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/$USERNAME && \
chmod 0440 /etc/sudoers.d/$USERNAME && \
usermod --uid $UID $USERNAME && \
groupmod --gid $GID $USERNAME
RUN gpasswd -a $USERNAME video
RUN gpasswd -a $USERNAME dialout
# Build dependencies installation
RUN apt-get update \
&& apt-get install -qq -y --no-install-recommends \
bash-completion \
bc \
can-utils \
command-not-found \
emacs \
freeglut3-dev \
gstreamer1.0-alsa \
gstreamer1.0-libav \
gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-base \
gstreamer1.0-plugins-good \
gstreamer1.0-plugins-ugly \
gstreamer1.0-tools \
i2c-tools \
iproute2 \
iputils-ping \
iw \
kbd \
kmod \
language-pack-en-base \
libapt-pkg-dev \
libcanberra-gtk3-module \
mesa-utils \
mtd-utils \
parted \
pciutils \
python3-pexpect \
sox \
sudo \
tmux \
vulkan-tools \
wireless-tools \
swig \
&& rm -rf /var/lib/apt/lists/*
# install ROS2 Humble Extras
RUN apt-get update && apt-get install -y --no-install-recommends \
ros-humble-robot-state-publisher* \
ros-humble-joint-state-publisher* \
ros-humble-xacro \
ros-humble-slam-toolbox \
ros-humble-ompl \
ros-humble-imu-tools \
lcov \
libxtensor-dev \
libgflags-dev \
nlohmann-json3-dev \
ros-dev-tools \
ros-humble-cartographer \
ros-humble-cartographer-rviz \
ros-humble-diagnostic-updater \
libgraphicsmagick++1-dev \
graphicsmagick-libmagick-dev-compat \
ros-humble-cyclonedds \
ros-humble-rmw-cyclonedds-cpp \
ros-humble-behaviortree-cpp-v3 \
ros-humble-ament* \
&& rm -rf /var/lib/apt/lists/*
# Optional Ydlidar install
RUN git clone https://github.com/YDLIDAR/YDLidar-SDK.git &&\
mkdir -p YDLidar-SDK/build && \
cd YDLidar-SDK/build &&\
cmake ..&&\
make &&\
make install &&\
cd .. &&\
pip install . &&\
cd .. && rm -r YDLidar-SDK
RUN wget -c https://github.com/google/glog/archive/refs/tags/v0.6.0.tar.gz -O glog-0.6.0.tar.gz &&\
tar -xzvf glog-0.6.0.tar.gz &&\
cd glog-0.6.0 &&\
mkdir build && cd build &&\
cmake .. && make -j4 &&\
make install &&\
ldconfig &&\
cd ../.. && rm -r glog-*
RUN wget -c https://github.com/Neargye/magic_enum/archive/refs/tags/v0.8.0.tar.gz -O magic_enum-0.8.0.tar.gz &&\
tar -xzvf magic_enum-0.8.0.tar.gz &&\
cd magic_enum-0.8.0 &&\
mkdir build && cd build &&\
cmake .. && make -j4 &&\
make install &&\
ldconfig &&\
cd ../.. && rm -r magic_enum*
RUN git clone https://github.com/libuvc/libuvc.git &&\
cd libuvc &&\
mkdir build && cd build &&\
cmake .. && make -j4 &&\
make install &&\
ldconfig &&\
cd ../.. && rm -r libuvc*
# OK we have to use sudo now as user jetson not root so put other stuff before here
USER $USERNAME
WORKDIR /home/$USERNAME
SHELL ["/bin/bash", "-l", "-c"]
ENV NVIDIA_VISIBLE_DEVICES all
ENV NVIDIA_DRIVER_CAPABILITIES graphics,utility,compute
ENV RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
ENV ROS_DISTRO=humble
ENV AGILEX_PORT=ttyTHS0
ENV YDLIDAR_DEV=/dev/ttyUSB0
ENV QT_X11_NO_MITSHM=1
ENV DISPLAY=0
RUN echo "source /opt/ros/humble/setup.bash" >> $HOME/.bashrc
# Install navigation2 from source overcoming issues on aarch64
# Including install all dependencies except ros-humble-gazebo-ros-pkgs
# Build all navigation2 packages except nav2_system_tests
# This is going to take a *long* time
RUN mkdir ${HOME}/ros2_extra_ws/src -p && \
cd ${HOME}/ros2_extra_ws/src && \
git clone https://github.com/ros-planning/navigation2.git && \
cd navigation2 && \
git checkout humble && \
cd ${HOME}/ros2_extra_ws && \
source /opt/ros/humble/setup.bash && \
rosdep check --from-paths src --ignore-src --rosdistro=humble 2>&1 | grep '^apt' | grep -v 'ros-humble-cv-bridge' | grep -v 'ros-humble-gazebo-ros-pkgs' | sed 's/apt\s\+//' | xargs -I {} sudo apt install -y {} && \
export CMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH:/opt/ros/humble:/opt/ros/humble/install/share/ && \
colcon build --symlink-install --cmake-args --packages-skip nav2_system_tests && \
echo "source ${HOME}/ros2_extra_ws/install/setup.bash" >> $HOME/.bashrc
@bwmcin
Copy link

bwmcin commented Apr 3, 2024

Thanks for the gist. I believe on your dockerfile for ROS2 humble jetpack 6, line 148 is missing '&&' before the backwards slash.

@brianlmerritt
Copy link
Author

Thanks for the gist. I believe on your dockerfile for ROS2 humble jetpack 6, line 148 is missing '&&' before the backwards slash.

Indeed! Fixed and thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment