Welcome to Jetson Orin NANO Developer Kit repository
04.Docker usage
Docker Usage
Docker Usage1. Start the Image2. ROS Environment Construction2.1. Update System Software2.2. Determine the Language Environment2.2.1. Verify the System Environment2.2.2. Set the UTF-8 Environment2.3. Set the Software Source2.4. Set the Key2.5. Install the ROS 1 Desktop Version2.6. Install ROS 1 Dependencies2.7. rosdep Initialization2.8. Set Environment Variables2.8.1. Temporary Setting2.8.2. Automatic Setting (Recommended)3. Commit the Image4. Verify the Image/ROS4.1. Start the Image4.2. Verify the ROS Environment
Historical Demonstration: This section shows building ROS 1 Melodic in an
ubuntu:18.04container, and is only intended for understanding the process of installing inside a container and committing an image. Both Ubuntu 18.04 and ROS 1 Melodic have reached end of regular support; this process is not an installation guide for the current Ubuntu 24.04 / ROS 2 Jazzy, and the repositories and dependencies may no longer be available.
1. Start the Image
Start the ubuntu:18.04 image in interactive mode:
docker run -it ubuntu:18.04 /bin/bash

2. ROS Environment Construction
Administrator privileges are not required inside Docker. If the ROS environment is installed on the host, sudo needs to be added to the commands.
2.1. Update System Software
Installing the ROS 1 environment generally requires ensuring that the system software package is up to date:
xxxxxxxxxxapt update && apt upgrade

2.2. Determine the Language Environment
Make sure the system language environment supports UTF-8!
2.2.1. Verify the System Environment
xxxxxxxxxxlocale

2.2.2. Set the UTF-8 Environment
If the system language does not support the UTF-8 environment, enter the following commands in the terminal line by line:
xxxxxxxxxxapt install localeslocale-gen en_US en_US.UTF-8update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8echo "export LANG=en_US.UTF-8" >> ~/.bashrcsource ~/.bashrc

2.3. Set the Software Source
xxxxxxxxxxapt install lsb-core
xxxxxxxxxxsh -c '. /etc/lsb-release && echo "deb http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'

2.4. Set the Key
xxxxxxxxxxapt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

2.5. Install the ROS 1 Desktop Version
The ROS desktop version includes ROS 1 core functions, common tools, and libraries:
xxxxxxxxxxapt update && apt upgrade
xxxxxxxxxxapt install ros-melodic-desktop-full -y

In the middle, you need to select the region and city by yourself: not demonstrated here

2.6. Install ROS 1 Dependencies
xxxxxxxxxxapt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential -y

2.7. rosdep Initialization
xxxxxxxxxxrosdep initrosdep update
If rosdep init reports a download error, first check the DNS, network proxy, and HTTPS connectivity to raw.githubusercontent.com of the container. Do not write a fixed IP obtained from a third party into /etc/hosts; GitHub addresses may change, and a fixed resolution causes subsequent connection errors.

Run again:
xxxxxxxxxxrosdep initrosdep update

2.8. Set Environment Variables
2.8.1. Temporary Setting
Refresh the environment variables of the current terminal:
xxxxxxxxxxsource /opt/ros/melodic/setup.bash
2.8.2. Automatic Setting (Recommended)
Refresh the environment variables automatically on terminal startup (by sourcing .bashrc).
xxxxxxxxxxecho "source /opt/ros/melodic/setup.bash" >> ~/.bashrcsource ~/.bashrc

3. Commit the Image
Only by committing a new image locally can the previously built ROS environment be saved; otherwise, the next time the docker image is started, there is still no ROS environment in the container.
Note: Modify according to the actual CONTAINER ID
xxxxxxxxxxdocker commit a31a521e9fb4 ros_melodic:1.0

After saving, you can close the ubuntu:18.04 container:

4. Verify the Image/ROS
4.1. Start the Image
Start the ros_melodic:1.0 image in interactive mode: since the turtle case needs to be displayed in the graphical interface, Docker needs to be allowed to access the X Display
xxxxxxxxxxxhost +si:localuser:root
Revoke the authorization after the container exits:
xxxxxxxxxxxhost -si:localuser:rootxxxxxxxxxxdocker run -it -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix ros_melodic:1.0 /bin/bash
4.2. Verify the ROS Environment
Use the turtle case to test the ROS environment: open three terminals to enter the same container, and then run the following commands respectively
xxxxxxxxxxroscore
xxxxxxxxxxrosrun turtlesim turtlesim_node
xxxxxxxxxxrosrun turtlesim turtle_teleop_key
Note: The mouse must stay in the third command window to control the turtle
