I'm working on a project for university. We have to containerize a Gazebo simulation using Docker.
While researching on how to do this I came across this link, and tried running the simulation shown in it. If it works I think we can just change some stuff and make it work for our project. This is the link detailing the simulation I'm trying to run: https://docs.aws.amazon.com/robomaker/latest/dg/run-hello-world-ros-2.html
All the code needed to reproduce what we have tried to do is found in that Amazon AWS guide so I won't paste it in here for the most part.
Some info on the system and the technologies we're working with:
- OS: Ubuntu 20.04 focal fossa
- Gazebo 11
- ROS2 Foxy
- NVIDIA GeForce rtx 2070 with version 510 drivers
The simulation is split in 3 images, Base, RobotApp and SimulationApp. We then run the 2 app images. When using the command "docker run" given in the example the first one creates a spinning object and seems to work just fine.
Docker command for the first one:
docker run -it -e DISPLAY -v /tmp/.X11-unix/:/tmp/.X11-unix/ --name robot_app \
-u robomaker -e ROBOMAKER_GAZEBO_MASTER_URI=http://localhost:5555 \
-e ROBOMAKER_ROS_MASTER_URI=http://localhost:11311 \
helloworldsampleappros2foxygazebo11robotapp:latest
Docker command for the second one:
docker run -it -e DISPLAY -v /tmp/.X11-unix/:/tmp/.X11-unix/ --name sim_app \
-u robomaker -e ROBOMAKER_GAZEBO_MASTER_URI=http://localhost:5555 \
-e ROBOMAKER_ROS_MASTER_URI=http://localhost:11311 \
helloworldsampleappros2foxygazebo11simapp:latest
The second one gives me this error message along some warnings:
[gzserver-1] libGL error: No matching fbConfigs or visuals found
[gzserver-1] libGL error: failed to load driver: swrast
Here's all the messages printed to console when running the second Docker command:
ROS_VERSION=2
NVIDIA_VISIBLE_DEVICES=all
GAZEBO_MASTER_URI=http://localhost:11345
ROS_PYTHON_VERSION=3
HOSTNAME=0ff33fe3f61a
ROBOMAKER_GAZEBO_MASTER_URI=http://localhost:5555
PWD=/home/robomaker/workspace/aws-robomaker-sample-application-helloworld-ros2/simulation_ws
NVIDIA_DRIVER_CAPABILITIES=graphics, display
ROBOMAKER_ROS_MASTER_URI=http://localhost:11311
HOME=/home/robomaker
GAZEBO_PLUGIN_PATH=/usr/lib/x86_64-linux-gnu/gazebo-11/plugins:
LANG=C.UTF-8
GAZEBO_MODEL_DATABASE_URI=http://models.gazebosim.org
AMENT_PREFIX_PATH=/home/robomaker/workspace/aws-robomaker-sample-application-helloworld-ros2/simulation_ws/install/turtlebot3_description_reduced_mesh:/home/robomaker/workspace/aws-robomaker-sample-application-helloworld-ros2/simulation_ws/install/hello_world_simulation:/opt/ros/foxy
CMAKE_PREFIX_PATH=/home/robomaker/workspace/aws-robomaker-sample-application-helloworld-ros2/simulation_ws/install/turtlebot3_description_reduced_mesh:/home/robomaker/workspace/aws-robomaker-sample-application-helloworld-ros2/simulation_ws/install/hello_world_simulation
GAZEBO_RESOURCE_PATH=/usr/share/gazebo-11:
COLCON_PREFIX_PATH=/home/robomaker/workspace/aws-robomaker-sample-application-helloworld-ros2/simulation_ws/install
PYTHONPATH=/opt/ros/foxy/lib/python3.8/site-packages
TERM=xterm
DISPLAY=:1
SHLVL=1
LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/gazebo-11/plugins:/opt/ros/foxy/opt/yaml_cpp_vendor/lib:/opt/ros/foxy/opt/rviz_ogre_vendor/lib:/opt/ros/foxy/lib/x86_64-linux-gnu:/opt/ros/foxy/lib:/usr/lib/x86_64-linux-gnu/gazebo-11/plugins:
ROS_LOCALHOST_ONLY=0
LC_ALL=C.UTF-8
GAZEBO_MODEL_PATH=/usr/share/gazebo-11/models:
PATH=/opt/ros/foxy/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
DEBIAN_FRONTEND=noninteractive
ROS_DISTRO=foxy
QT_X11_NO_MITSHM=1
OGRE_RESOURCE_PATH=/usr/lib/x86_64-linux-gnu/OGRE-1.9.0
OLDPWD=/
_=/usr/bin/printenv
[INFO] [launch]: All log files can be found below /home/robomaker/.ros/log/2022-02-04-12-17-26-791225-0ff33fe3f61a-39
[INFO] [launch]: Default logging verbosity is set to INFO
/home/robomaker/workspace/aws-robomaker-sample-application-helloworld-ros2/simulation_ws/install/turtlebot3_description_reduced_mesh/share/turtlebot3_description_reduced_mesh/launch/spawn_turtlebot.launch.py:61: UserWarning: The parameter 'node_executable' is deprecated, use 'executable' instead
Node(
[INFO] [gzserver-1]: process started with pid [41]
[INFO] [spawn_entity.py-2]: process started with pid [43]
[spawn_entity.py-2] [INFO] [1643977047.395921509] [spawn_entity]: Spawn Entity started
[spawn_entity.py-2] [INFO] [1643977047.396308383] [spawn_entity]: Loading entity XML from file /home/robomaker/workspace/aws-robomaker-sample-application-helloworld-ros2/simulation_ws/install/turtlebot3_description_reduced_mesh/share/turtlebot3_description_reduced_mesh/urdf/turtlebot3_waffle_pi.urdf
[spawn_entity.py-2] [INFO] [1643977047.398652203] [spawn_entity]: Waiting for service /spawn_entity, timeout = 30
[spawn_entity.py-2] [INFO] [1643977047.399013641] [spawn_entity]: Waiting for service /spawn_entity
[gzserver-1] libGL error: No matching fbConfigs or visuals found
[gzserver-1] libGL error: failed to load driver: swrast
[spawn_entity.py-2] [INFO] [1643977047.904187249] [spawn_entity]: Calling service /spawn_entity
[gzserver-1] [WARN] [1643977048.247457510] [rcl]: Found remap rule '~/out:=imu'. This syntax is deprecated. Use '--ros-args --remap ~/out:=imu' instead.
[gzserver-1] [INFO] [1643977048.250959996] [turtlebot3_imu]: <initial_orientation_as_reference> is unset, using default value of false to comply with REP 145 (world as orientation reference)
[gzserver-1] [WARN] [1643977048.251600689] [rcl]: Found remap rule '~/out:=imu'. This syntax is deprecated. Use '--ros-args --remap ~/out:=imu' instead.
[spawn_entity.py-2] [INFO] [1643977048.335266898] [spawn_entity]: Spawn status: SpawnEntity: Successfully spawned entity [robot]
[gzserver-1] [WARN] [1643977048.341230833] [rcl]: Found remap rule '~/out:=scan'. This syntax is deprecated. Use '--ros-args --remap ~/out:=scan' instead.
[gzserver-1] [WARN] [1643977048.344790289] [rcl]: Found remap rule '~/out:=scan'. This syntax is deprecated. Use '--ros-args --remap ~/out:=scan' instead.
[INFO] [spawn_entity.py-2]: process has finished cleanly [pid 43]
[gzserver-1] [INFO] [1643977048.476454488] [turtlebot3_diff_drive]: Wheel pair 1 separation set to [0.287000m]
[gzserver-1] [INFO] [1643977048.476502091] [turtlebot3_diff_drive]: Wheel pair 1 diameter set to [0.066000m]
[gzserver-1] [INFO] [1643977048.477502575] [turtlebot3_diff_drive]: Subscribed to [/cmd_vel]
[gzserver-1] [INFO] [1643977048.478593142] [turtlebot3_diff_drive]: Advertise odometry on [/odom]
[gzserver-1] [INFO] [1643977048.479685530] [turtlebot3_diff_drive]: Publishing odom transforms between [odom] and [base_footprint]
[gzserver-1] [WARN] [1643977048.487264720] [rcl]: Found remap rule '~/out:=joint_states'. This syntax is deprecated. Use '--ros-args --remap ~/out:=joint_states' instead.
[gzserver-1] [INFO] [1643977048.490953326] [turtlebot3_joint_state]: Going to publish joint [wheel_left_joint]
[gzserver-1] [INFO] [1643977048.490991604] [turtlebot3_joint_state]: Going to publish joint [wheel_right_joint]
[gzserver-1] [WARN] [1643977048.491042853] [rcl]: Found remap rule '~/out:=joint_states'. This syntax is deprecated. Use '--ros-args --remap ~/out:=joint_states' instead.
After this I follow the last set of instructions:
# Enable access to X server to launch Gazebo from docker container
$ xhost +
# Check that the robot_app and sim_app containers are running. The command should list both containers
$ docker container ls
# Connect to the sim app container
$ docker exec -it sim_app bash
# Launch Gazebo from within the container
$ /home/robomaker/simulation-entrypoint.sh ros2 launch gazebo_ros gzclient.launch.py
And get the following error:
[gzclient -1] libGL error: No matching fbConfigs or visuals found
[gzclient -1] libGL error: failed to load driver: swrast
[gzclient -1] libGL error: No matching fbConfigs or visuals found
[gzclient -1] libGL error: failed to load driver: swrast
[gzclient -1] Segmentation fault (core dumped)
[ERROR] [gzclient -1]: process has died [pid 156, exit code 139, cmd 'gzclient '].
Here's all the messages printed to console when running the commands above:
ROS_VERSION=2
NVIDIA_VISIBLE_DEVICES=all
GAZEBO_MASTER_URI=http://localhost:11345
ROS_PYTHON_VERSION=3
HOSTNAME=0ff33fe3f61a
ROBOMAKER_GAZEBO_MASTER_URI=http://localhost:5555
PWD=/home/robomaker/workspace/aws-robomaker-sample-application-helloworld-ros2/simulation_ws
NVIDIA_DRIVER_CAPABILITIES=graphics, display
ROBOMAKER_ROS_MASTER_URI=http://localhost:11311
HOME=/home/robomaker
GAZEBO_PLUGIN_PATH=/usr/lib/x86_64-linux-gnu/gazebo-11/plugins:
LANG=C.UTF-8
GAZEBO_MODEL_DATABASE_URI=http://models.gazebosim.org
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
AMENT_PREFIX_PATH=/home/robomaker/workspace/aws-robomaker-sample-application-helloworld-ros2/simulation_ws/install/turtlebot3_description_reduced_mesh:/home/robomaker/workspace/aws-robomaker-sample-application-helloworld-ros2/simulation_ws/install/hello_world_simulation:/opt/ros/foxy
CMAKE_PREFIX_PATH=/home/robomaker/workspace/aws-robomaker-sample-application-helloworld-ros2/simulation_ws/install/turtlebot3_description_reduced_mesh:/home/robomaker/workspace/aws-robomaker-sample-application-helloworld-ros2/simulation_ws/install/hello_world_simulation
GAZEBO_RESOURCE_PATH=/usr/share/gazebo-11:
COLCON_PREFIX_PATH=/home/robomaker/workspace/aws-robomaker-sample-application-helloworld-ros2/simulation_ws/install
PYTHONPATH=/opt/ros/foxy/lib/python3.8/site-packages
TERM=xterm
DISPLAY=:1
SHLVL=2
LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/gazebo-11/plugins:/opt/ros/foxy/opt/yaml_cpp_vendor/lib:/opt/ros/foxy/opt/rviz_ogre_vendor/lib:/opt/ros/foxy/lib/x86_64-linux-gnu:/opt/ros/foxy/lib:/usr/lib/x86_64-linux-gnu/gazebo-11/plugins:
ROS_LOCALHOST_ONLY=0
LC_ALL=C.UTF-8
GAZEBO_MODEL_PATH=/usr/share/gazebo-11/models:
PATH=/opt/ros/foxy/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
DEBIAN_FRONTEND=noninteractive
ROS_DISTRO=foxy
QT_X11_NO_MITSHM=1
OGRE_RESOURCE_PATH=/usr/lib/x86_64-linux-gnu/OGRE-1.9.0
OLDPWD=/
_=/usr/bin/printenv
[INFO] [launch]: All log files can be found below /home/robomaker/.ros/log/2022-02-04-12-17-58-244883-0ff33fe3f61a-124
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [gzclient -1]: process started with pid [156]
[gzclient -1] libGL error: No matching fbConfigs or visuals found
[gzclient -1] libGL error: failed to load driver: swrast
[gzclient -1] libGL error: No matching fbConfigs or visuals found
[gzclient -1] libGL error: failed to load driver: swrast
[gzclient -1] Segmentation fault (core dumped)
[ERROR] [gzclient -1]: process has died [pid 156, exit code 139, cmd 'gzclient '].
That said we checked every post for hours to try to fix this:
[gzserver-1] libGL error: No matching fbConfigs or visuals found
[gzserver-1] libGL error: failed to load driver: swrast
but it still does not work. We tried reinstalling NVIDIA drivers, found a bunch of posts about some Mesa drivers that give this error, but i checked and i don't have Mesa under my driver files. This is the forum: https://askubuntu.com/questions/834254/steam-libgl-error-no-matching-fbconfigs-or-visuals-found-libgl-error-failed-t
And this is what i get after running sudo ldconfig -p | grep -i gl.so
:
libwayland-egl.so.1 (libc6,x86-64) => /lib/x86_64-linux-gnu/libwayland-egl.so.1
libcogl.so.20 (libc6,x86-64) => /lib/x86_64-linux-gnu/libcogl.so.20
libQt5OpenGL.so.5 (libc6,x86-64) => /lib/x86_64-linux-gnu/libQt5OpenGL.so.5
libQt5OpenGL.so (libc6,x86-64) => /lib/x86_64-linux-gnu/libQt5OpenGL.so
libOpenGL.so.0 (libc6,x86-64) => /lib/x86_64-linux-gnu/libOpenGL.so.0
libOpenGL.so.0 (libc6) => /lib/i386-linux-gnu/libOpenGL.so.0
libOpenGL.so (libc6,x86-64) => /lib/x86_64-linux-gnu/libOpenGL.so
libGL.so.1 (libc6,x86-64) => /lib/x86_64-linux-gnu/libGL.so.1
libGL.so.1 (libc6) => /lib/i386-linux-gnu/libGL.so.1
libGL.so (libc6,x86-64) => /lib/x86_64-linux-gnu/libGL.so
libEGL.so.1 (libc6,x86-64) => /lib/x86_64-linux-gnu/libEGL.so.1
libEGL.so.1 (libc6) => /lib/i386-linux-gnu/libEGL.so.1
libEGL.so (libc6,x86-64) => /lib/x86_64-linux-gnu/libEGL.so
We also tought maybe we're missing openGL or something similar inside the Dockerfile so we tried to get Hardware acceleration to work, following instructions here: http://wiki.ros.org/docker/Tutorials/Hardware%20Acceleration and so we have tried installing nvidia-docker2.
If we run nvidia-docker version
we get:
NVIDIA Docker: 2.8.0
Client: Docker Engine - Community
Version: 20.10.12
API version: 1.41
Go version: go1.16.12
Git commit: e91ed57
Built: Mon Dec 13 11:45:33 2021
OS/Arch: linux/amd64
Context: default
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 20.10.12
API version: 1.41 (minimum version 1.12)
Go version: go1.16.12
Git commit: 459d0df
Built: Mon Dec 13 11:43:42 2021
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.4.12
GitCommit: 7b11cfaabd73bb80907dd23182b9347b4245eb5d
runc:
Version: 1.0.2
GitCommit: v1.0.2-0-g52b36a2
docker-init:
Version: 0.19.0
GitCommit: de40ad0
We followed the instructions provided here: https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/user-guide.html to set the environmental variables we need to control which libraries will be mounted in the container.
Since our error seems to indicate that OpenGL is missing I added
ENV NVIDIA_VISIBLE_DEVICES all
ENV NVIDIA_DRIVER_CAPABILITIES graphics, display
to the first Dockerfile. graphics
is required for openGL and display
for x11 display (which I think we use since something about it is written in the original Dockerfile, but I'm not sure about it).
After all this and some more, we still get those errors.