Skip to content

Visualization

Visualization is crucial during development to understand the behavior of estimators and controllers. This page describes the visualization tools available in the project. We make use of RViz, a 3D visualization tool for ROS, and PlotJuggler, a time series visualization tool.

Available tools

When running an experiment inside the container, RViz and PlotJuggler can be launched alongside an experiment.

# roslaunch crs_launch sim_single_car.launch view_rviz:=true view_plotjuggler:=true

By default, RViz is displayed and PlotJuggler is not.

Setting up the visualization tools

All graphical user interfaces are run from the CRS Docker container. To interface with the container, on Linux an X server is required. On macOS and other platforms where the X server is not supported, and a workaround is to use noVNC. The following steps describe how to access the visualization tools:

noVNC (macOS)

When running the CRS Docker container, either through crs-docker run or the development container, the noVNC server is started automatically.

Access the web-based desktop environment: http://localhost:8080/vnc.html

X11 (Linux)

On Linux, the VNC server is not started automatically. Instead, you should perform the following steps:

  1. Install an X server on your host machine. For example, on Ubuntu, you can install XQuartz by running
sudo apt-get install xorg xauth
  1. Permit the root user to connect to the X server by running
xhost +local:root
Detailed information about X11

X11 (also known as X Window System) is a graphical windowing system used in Unix and Unix-like operating systems. GUI applications communicate with X11 to create windows, accept user input, and display things on the screen.

Normally, Docker containers are used for headless applications (those without a GUI), but they can be configured to run GUI applications by routing display output to the host's X server.

Here's how it works in the context of the Docker Compose file:

/tmp/.X11-unix:/tmp/.X11-unix:rw in the volumes section: This mounts the X11 Unix socket from the host to the container, effectively providing the container access to the host's X server. This allows the container to create windows and receive user input.

DISPLAY=$DISPLAY in the environment section: The DISPLAY environment variable is crucial for X11. It tells applications where to send their display output. By setting DISPLAY=$DISPLAY in the container, it's telling GUI applications in the container to send their display output to the same display as the host machine.

QT_X11_NO_MITSHM=1 in the environment section: This is a specific setting for Qt applications. By default, Qt applications use the MIT Shared Memory (MIT-SHM) extension of X11 for improved performance. However, this can cause issues in containerized applications because the shared memory segment is not accessible to the container. This setting disables the use of MIT-SHM for Qt applications.

XAUTHORITY=/tmp/.docker.xauth: X11 uses a mechanism called Xauthority to manage authentication. By specifying the XAUTHORITY variable, the Docker container is told where to check for X11 authorization credentials.

Essentially, these settings create a bridge between the Docker container and the host's X server, allowing GUI applications in the container to create windows and receive user input just as if they were running directly on the host machine.

This configuration is specific to Unix-like systems, including Linux and MacOS. If you're running Docker on a Windows machine, additional steps would be required to enable X11 forwarding.

Troubleshooting

X11 (Linux)

  • Check that xorg, xauth are installed (sudo apt-get install xorg xauth)
  • Check xterm, xeyes to ensure service is running on host (systemctl status display-manager)
  • Check /tmp/.X11-unix directory rights (rwx) -> ensure mounting is done properly (i.e. check that executables were available in host and mounted successfully on container).
  • Ensure that user is added to the docker group (sudo usermod -aG docker username), using the correct username
  • Check $DISPLAY variable, should match on host and remote (environment variable should be either :0 or :1)
  • Check that you are using the debian pkg (docker-ce) over the snap one: https://community.openhab.org/t/solved-docker-help-error-creating-mount-source/62837

Related links:

https://answers.ros.org/question/300113/docker-how-to-use-rviz-and-gazebo-from-a-container/
https://stackoverflow.com/questions/68036484/qt6-qt-qpa-plugin-could-not-load-the-qt-platform-plugin-xcb-in-even-thou
https://unix.stackexchange.com/questions/196677/what-is-tmp-x11-unix