Sign inSign up

magic4wei/ros

By magic4wei

Updated over 2 years ago

ROS base images for development and tests. Support OpenGL rendering with tag `*-gui`.

Image
0

296

magic4wei/ros repository overview

Installed Packages

ROS base images magic4wei/ros:<ros-distro>-desktop-<ubuntu-distro> in this repository are built from osrf/ros:<ros-distro>-desktop and have Installed the following packages for more convenient development and test:

  • Utils: apt-utils, lsb-release, ca-certificates openssl
  • Download files: git, wget, curl
  • Archive, compress and uncompress: tar, gzip, lzip. bzip2. xz-utils, lzma, lzop

Additional GUI-related packages are also installed in images magic4wei/ros:<ros-distro>-desktop-<ubuntu-distro>-gui to enable OpenGL rendering and X display.

Usage

Explore ROS Base Images

Get started with base image magic4wei/ros:<ros-distro>-desktop-<ubuntu-distro>-gui If you want to run a GUI application that requires OpenGL rendering (see tutorial below). Otherwise magic4wei/ros:<ros-distro>-desktop-<ubuntu-distro> would be better since it has smaller size.

ROS base images all have an entrypoint script located at /ros_entrypoint.sh:

#!/bin/bash
set -e

# setup ros environment
source "/opt/ros/$ROS_DISTRO/setup.bash" --
exec "$@"

This entrypoint allows us to execute successive commands after ros environment setup.

Explore more about base images by running

# ROS Melodic for example
docker run -it --rm magic4wei/ros:melodic-desktop-bionic  # no OpenGL rendering is supported
docker run -it --rm magic4wei/ros:melodic-desktop-bionic-gui  # enable OpenGL rendering, see tutorial below
Work with OpenGL Rendering

Base image magic4wei/ros:*-gui have already installed required packages to enable OpenGL rendering in container. Before you go through this tutorial, make sure that

  • at least one GPU is mounted on your machine
  • GPU driver is installed correctly
  • You can run glxgears in terminal without any error (package mesa-utils is needed)

Firstly, you need to run xhost + on your host machine to enable X client display.

For Intel GPU, simply run

docker run -it --rm \
-e DISPLAY=$DISPLAY \
-v /tmp/.X11-unix:/tmp/.X11-unix:rw \
--privileged \
--device=/dev/dri:/dev/dri \
magic4wei/ros:melodic-desktop-bionic-gui

For Nvidia GPU, it is a little bit more complicated. We need to connect Nvidia driver volume when docker image runs, and add Nvidia OpenGL library path to LD_LIBRARY_PATH inside the container. If you want to run Nvidia executable tools like nvidia-smi, you also need to add their path to PATH inside the container.

For example, I have installed Nvidia driver nvidia-430 at /usr/lib/nvidia-430 and /usr/lib32/nvidia-430 (32-bit compatible libraries), and all my Nvidia tools are located at /usr/lib/nvidia-430/bin. Two steps to enable OpenGL rendering in container:

  1. Run image with Nvidia driver volume bindings
docker run -it --rm \
-e DISPLAY=$DISPLAY \
-v /tmp/.X11-unix:/tmp/.X11-unix:rw \
--privileged \
-v /usr/lib/nvidia-430:/usr/hostLib/lib/nvidia \
-v /usr/lib32/nvidia-430:/usr/hostLib/lib32/nvidia \
magic4wei/ros:melodic-desktop-bionic-gui
  1. Add Nvidia OpenGL library path in the container
export LD_LIBRARY_PATH=/usr/hostLib/lib/nvidia:/usr/hostLib/lib32/nvidia:${LD_LIBRARY_PATH} # required for OpenGL rendering
export PATH=/usr/hostLib/lib/nvidia/bin:${PATH} # optional, add this if you want to run tools like nvidia-smi

Then you are able to run Rviz or other GUI applications that requires OpenGL rendering in the container. For example,

# Example 1: Run Rviz
roscore & rviz

# Example 2: Run glxgears (needs `mesa-utils`, already installed in GUI base images)
glxgears

Tag summary

Content type

Image

Digest

sha256:16c1b5f70

Size

875.4 MB

Last updated

over 2 years ago

docker pull magic4wei/ros:melodic-desktop-full-bionic-gui