ROS GUI in docker

This post documented my experiments on VINS and ros under docker.

VINS-RGBD Development guide

VINS-RGBD is evolved from VINS-Mono, and has been suited for realsense D455, this tutorial meant to explore this algorithm for RGBD camera and do SLAM on low-cost machines.

Test Env Build

Before start here is a test playground for us to do algorithm optimization, we are conducting all the experiments on docker. Please make sure you have successfully installed docker-CE, and nvidia-container-runtime:

# apt install dependencies
$ 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

# docker service restart
$ sudo systemctl restart docker.service

Register user ID in docker

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

build docker image

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

execute the docker container, this will create a x11 forward gui terminal for your application

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

Then you will be able to open all the gui applications like you are in the host machine

vins_rgbd_d455.png


test Rig: D455 OS: Ubuntu 18.04 —

The following command helps to export the topics of realsense sensor, what it does is its publishing color image and aligned depth image to rgb coordinate with RGB/depth frame rate at 30 fps and IMU frame rate at 200 fps.

roslaunch realsense2_camera rs_camera.launch device_type:=d455 enable_gyro:=true enable_accel:=true align_depth:=true unite_imu_method:=linear_interpolation color_width:=640 color_height:=480 color_fps:=30 depth_width:=640 depth_height:=480 depth_fps:=30

install opencv 3.4 with ppa:

sudo add-apt-repository ppa:timsc/opencv-3.4
sudo apt install libopencv*3.4*

Use the following command to query the intrisics and extrinsics:

rs-enumerate-devices -c

For extrinsics, what you need is color to gyro/accelerator, which is the [R|t] transformation matrix converting from camera coordinate to IMU coordinate.

Extrinsic from "Color"	  To	  "Gyro" :
 Rotation Matrix:
   0.999997         0.00215989      -0.000678808   
  -0.00215933       0.999997         0.000815037   
   0.000680566     -0.000813569      0.999999      

 Translation Vector: 0.0290079656988382  0.00740037159994245  0.0156494211405516

and for intrinsics, what you need is the fx, fy, cx, cy and distortion matrix:

 Intrinsic of "Color" / 640x480 / {YUYV/RGB8/BGR8/RGBA8/BGRA8/Y16}
  Width:      	640
  Height:     	480
  PPX:        	311.377532958984
  PPY:        	247.430999755859
  Fx:         	381.151916503906
  Fy:         	380.847564697266
  Distortion: 	Inverse Brown Conrady
  Coeffs:     	-0.0573863908648491  	0.0686274990439415  	-0.000280521548120305  	-0.000220020971028134  	-0.0218628235161304  
  FOV (deg):  	80.02 x 64.42

Here Coeffs means [k1, k2, p1, p2, p3].

Here’s my configuration for D455 with EuRoC setup:

realsense_color_config_d455.yaml

Good luck!

Written on March 11, 2019