DEV Community

Adarsh TS
Adarsh TS

Posted on


Run Nav2 in a Docker Container

Nav2 is the Navigation stack for ROS2 (foxy). This post lists out the step required to setup and test Nav2 stack inside a Docker container.

Install Docker by going though the Docker Docs.

Pull the ROS2 docker image from

docker pull tsadarsh/ros2-foxy

To view the GUI applications like RViz and Gazebo, enable clients to access your device XServer:

xhost +

Set DISPLAY variable and mount X11 unix-domain socket to pipe the GUI applications outside the container:

docker run -it -e DISPLAY=$DISPLAY -v /tmp/.X11-unix/:/tmp/.X11-unix/ tsadarsh/ros2-foxy

Run a sudo apt update

Follow the Getting started guide from the official ROS2 docs and install:

sudo apt install ros-foxy-navigation2
sudo apt install ros-foxy-nav2-bringup
Enter fullscreen mode Exit fullscreen mode

Install the Turtlebot 3 packages:

sudo apt install ros-foxy-turtlebot3*

To run the example, first source the foxy setup.bash and set the environment variables:

source /opt/ros/<ros2-distro>/setup.bash
export TURTLEBOT3_MODEL=waffle
export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:/opt/ros/<ros2-distro>/share/turtlebot3_gazebo/models
Enter fullscreen mode Exit fullscreen mode

Finally launch the example turtlebot3 simulation:

ros2 launch nav2_bringup headless:=False

Note: Gazebo initially takes 5-10 minutes to start, download and cache all the required models. Until then the screen appears to be frozen.

If you encounter this error: libGL error: MESA-LOADER: failed to open amdgpu: /usr/lib/dri/ cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri), then mount /dev/dri to your container:

docker run -it -e DISPLAY=$DISPLAY -v /tmp/.X11-unix/:/tmp/.X11-unix/ -v /dev/dri:/dev/dri tsadarsh/ros2-foxy

Latest comments (0)

An Animated Guide to Node.js Event Loop

Node.js doesn’t stop from running other operations because of Libuv, a C++ library responsible for the event loop and asynchronously handling tasks such as network requests, DNS resolution, file system operations, data encryption, etc.

What happens under the hood when Node.js works on tasks such as database queries? We will explore it by following this piece of code step by step.