Simulate robot navigation inside Docker
Summary
Run Nav2 quickstart inside Docker

Why
- Reduce setup steps by getting ROS pre-installed
- Develop navigation applications in the safety of an isolated Docker environment
- Encourage development with ease of use
Specs
- Nav2
- ROS galactic Geochelone [switched from Humble for stability]
- tested on Ubuntu 20.04
Steps
- Get docker image. Test that it’s working with this example
docker pull osrf/ros:galactic-desktop - Connect docker to linux display
export DISPLAY=:0.0 xhost +local:docker - Run docker
docker run -it --net=host --device /dev/dri/ -e DISPLAY=$DISPLAY -v $HOME/.Xauthority:/root/.Xauthority:ro osrf/ros:galactic-desktop - Install nav2
apt update apt install ros-galactic-navigation2 -y apt install ros-galactic-nav2-bringup -y apt install ros-galactic-turtlebot3* -y - Load ROS environment variables
source /opt/ros/galactic/setup.bash export TURTLEBOT3_MODEL=waffle export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:/opt/ros/galactic/share/turtlebot3_gazebo/models - Run navigation example
ros2 launch nav2_bringup tb3_simulation_launch.py headless:=False - [Optional] Add workspace tools
apt install vim -y apt install tmux -y - Save progress to workspace
# in a separate terminal docker ps docker commit 3204cbea0e30 osrf/ros:galactic-desktop-nav2
Fixes for common errors
[ERROR] [rviz2-5]: process has died [pid 75, exit code -11, cmd '/opt/ros/galactic/lib/rviz2/rviz2 -d /opt/ros/galactic/share/nav2_bringup/rviz/nav2_default_view.rviz --ros-args']
- Run the following:
export DISPLAY=:0.0 xhost +local:dockerError: Non-unique names detected in type collision in <link name='camera_link'> - reinstall turtlebot packages
apt remove --purge ros-galactic-turtlebot3* apt install ros-galactic-turtlebot3* -y
References
Enjoy Reading This Article?
Here are some more articles you might like to read next: