Display ROS application on Docker with GUI on host side

Overview

Verification environment

The environment verified this time is as follows.

Hardware cpu - AMD Ryzen 9 3900X gpu - Geforce RTX 2060 super ram - 32G

Software os - ubuntu 20.04.1 kernel - Linux define 5.4.0-48-generic docker - 19.03.13 nvidia-driver - 450.66 cuda version - 11.0

I have attached the output of nvidia-smi.

$ nvidia-smi
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 450.66       Driver Version: 450.66       CUDA Version: 11.0     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  GeForce RTX 206...  Off  | 00000000:0E:00.0  On |                  N/A |
| 38%   40C    P8    11W / 175W |    916MiB /  7979MiB |      1%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+

Environmental arrangement

First install nvidia-container-runtime.

#apt related settings
$ curl -s -L https://nvidia.github.io/nvidia-container-runtime/gpgkey | sudo apt-key add -
$ distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
$ curl -s -L https://nvidia.github.io/nvidia-container-runtime/$distribution/nvidia-container-runtime.list | sudo tee /etc/apt/sources.list.d/nvidia-container-runtime.list

# nvidia-container-runtime installation
$ sudo apt update
$ sudo apt install nvidia-container-runtime

#Restart docker service
$ sudo systemctl restart docker.service

Then register your UID in docker group. I think people using docker are doing it, but just in case.

$ sudo usermod -a -G docker `id -un`
$ sudo systemctl restart docker.service

Execution method

Next, build the docker image.

$ git clone https://github.com/chikuta/chikuta-dockerfiles.git
$ cd chikuta-dockerfiles
$ ./docker/ros-bionic-melodic/build-docker-image.bash

Next, you can start the container of the built image by executing the following command. The content of the script is a wrapping of the processing around xhost and the arguments of docker. You can create your own environment by editing it as needed, so let's actively customize it.

$ cd chikuta-dockerfiles
$ ./docker/ros-bionic-melodic/run-docker-container.bash

When you execute the script, terminator will be launched. Since this is a terminal application running on the docker container, all commands executed here will be processed on the docker container.

It's fashionable to change the console from the default red to blue. terminator.png

The idea of starting terminator is based on the dockerfile of shadow-robot. Since the head family is an excessive specification that executes ansible on the docker file, I extracted only the necessary parts and summarized it compactly.

Finally, let's launch a basic GUI application.

# 1st terminal
$ roscore

# 2nd terminal
$ rviz

# 3rd terminal
$ gazebo

gazebo_rviz.png

reference

Recommended Posts

Display ROS application on Docker with GUI on host side
Run GUI application on Docker container
Run Ubuntu + ROS with Docker on Mac
Run GUI application on Docker container (Japanese input)
Display Mat type image on GUI with Swing
Web application built with docker (1)
Time is wrong with the application launched on the Docker container
WordPress with Docker Compose on CentOS 8
Web application creation with Nodejs with Docker
ubuntu: 20.04 Consideration memo to output GUI (output xeyes) to host side in docker container
Scraping with puppeteer in Nuxt on Docker.
Display API specifications with Laravel + SwaggerUI + Docker
Deploy your application with VPC + EC2 + Docker.
Build an environment with Docker on AWS
Launched Redmine with Docker on Raspberry Pi 3
How to share on the host side (windows) and guest side (CentOS 7) with VirtualBox
Try running MPLS-VPN with FR Routing on Docker
Introducing Rspec with Ruby on Rails x Docker
Environment construction command memo with Docker on AWS
Try running OSPF with FR Routing on Docker
Run JSP Hello World with Tomcat on Docker
Notes on building Rails6 / PostgreSQL with Docker Compose
Run an application made with Go on Heroku
Update container image with KUSANAGI Runs on Docker
Easy to display hello world with Rails + Docker
About the mechanism when displaying the GUI with Docker
[Rails AWS Docker] Build an existing Ruby on Rails + MySQL application with Docker and deploy it on AWS (5)
[Rails AWS Docker] Build an existing Ruby on Rails + MySQL application with Docker and deploy it on AWS (6)
[Rails AWS Docker] Build an existing Ruby on Rails + MySQL application with Docker and deploy it on AWS (3)
[Rails AWS Docker] Build an existing Ruby on Rails + MySQL application with Docker and deploy it on AWS (2)
[Rails AWS Docker] Build an existing Ruby on Rails + MySQL application with Docker and deploy it on AWS (1)
[Rails AWS Docker] Build an existing Ruby on Rails + MySQL application with Docker and deploy it on AWS (4)