Skip to content
Have a whale of a time running Semi-Direct Visual Odometry (SVO 2.0) for ROS in Docker! 🐳
Dockerfile Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
assets Add Dockerfile and Documentation Sep 5, 2019
.gitignore
Dockerfile Add Dockerfile and Documentation Sep 5, 2019
LICENSE Initial commit Sep 5, 2019
README.md
svo_entrypoint.sh

README.md

svo_ros Docker Template

A Docker container for easily running the Semi-Direct Visual Odometry 2.0 (SVO) visual odometry algorithm by ETHz with ROS!

Introduction

ohgodwhy

As amazing as the SVO ROS example package is, even detailing installation steps, it's hard to get it set up on some systems, especially since the supported systems are less widely used or straight up deprecated nowadays.

So why not use Docker to help preserve the environments and allow SVO to run on all sorts of systems and environments with minimal overhead?

Cheers!

Pre-Requisites

  • Docker 🐳
  • The SVO Binaries
    • Specifically the one for x86_64 Ubuntu 16.04
    • (Named svo_binaries_1604_kinetic)
    • I'd include it as a wget call in the Dockerfile script, but I don't want to break any licenses

Setup

Pre-Setup

Once you've downloaded your binaries, do place them in the root of this repository.

So your file tree should look something like this:

svo_ros_docker
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ README.md
β”œβ”€β”€ svo_entrypoint.sh
└── svo_binaries_1604_kinetic/
   └── rpg_svo_example/
   └── svo_install_ws/
   └── ...

Build The Image!

# Run this in the root of the repository (where the Dockerfile is)
docker build -t ros:svo .

Validation

Run the Demo!

1567671142676

We'll need to download the demo bag file. Save it somewhere accessible on your host computer.

On Host Computer

We didn't enable GUI in the Docker container because some machines (typically with NVIDIA GPUs) can't run the relevant GUIs without bloating the container! (This is mainly because RViz uses OpenGL, and it can get a bit tricky to set up properly. Also, because we didn't install RViz on the container to keep it lean.)

Thankfully we can run visualisations on our host machine instead.

# In one terminal, ensure your ROS_MASTER_URI is not on localhost,
# Then start a ROS master first!
export ROS_MASTER_URI=http://127.0.0.1:11311
roscore

# Then in another terminal, navigate to the rpg_svo_example on your host, and run RVIZ
export ROS_MASTER_URI=http://127.0.0.1:11311
cd <svo_ros_docker_repo_dir>/svo_binaries_1604_kinetic/rpg_svo_example/svo_ros
rviz -d rviz_config.rviz

In SVO_ROS Docker Container

# Spin up the Docker container and make it ephemeral
# Remember to set network to host! We'll also just do local for IPs
docker run -it \
           --rm \
           --net=host \
           -e ROS_IP=127.0.0.1 \
           ros:svo

# Once inside the Docker container we'll source the workspace and run the demo!
source svo_ws/devel/setup.bash
roslaunch svo_ros run_from_topic.launch cam_name:=svo_test_pinhole

Play Bag!

# Finally, in your host machine, play the bag file
export ROS_MASTER_URI=http://127.0.0.1:11311
export ROS_IP=127.0.0.1

cd <bagfile_directory>
rosbag play svo_test_short.bag

Deploying svo_ros from the Docker Container

If you actually want to use the SVO_ROS Docker container in a deployment context, just properly set your ROS_MASTER_URI and ROS_IP to whatever you need.

There are also some things to take note of:

  • Because using the svo_ros package in a deployment context will require you to have certain calibration files handy, we'll need to create a persisting container. Run the docker run command once.

  • While you can do crazy stuff like mount volumes and stuff for your convenience, I won't be going through that here

    • Instead, if you want to make your own customised SVO pipeline, you will need to:

      1. Get your own calibration camchain made from Kalibr and put it into the container's /home/svo_ws/src/rpg_svo_example/svo_ros/calib.

        # To copy files into a container
        docker cp <host_file_path> <container_name>:<container_file_dest_path>
      2. Do the same thing but for the param file in /home/svo_ws/src/rpg_svo_example/svo_ros/param.

      3. Edit the run_from_topic.launch launchfile to accept your own camera's topics, and your own special param file, or create your own launchfile based off of it for yourself.

    • If you're really lazy to keep copying files back and forth, you can also just edit the files you've copied in directly. I made sure the container has nano.

    • Or if you want to be really efficient, you can just mount a volume in the docker run command and point the launchfile to those volumes. Then you can just edit the files on your host, and they should be reflected in the container.

# Create the container
# In this case, we name it svo_rawr
docker run -it \
           --net=host \
           -e ROS_MASTER_URI=http://<YOUR_MASTER_URI_HERE>:11311 \
           -e ROS_IP=<YOUR_HOST_IP> \
           --name=svo_rawr \
           ros:svo
           
# For subsequent runs, use docker exec after starting the container
docker start svo_rawr
docker exec -it svo_rawr bash

# If you need to change the IPs for some reason, inside the container, re-export them
# Or, alternatively, just remake the container
export ROS_MASTER_URI=http://<new_master_uri>:11311
export ROS_IP=<YOUR_HOST_IP>

# After which you can run it as above
source svo_ws/devel/setup.bash
roslaunch svo_ros run_from_topic.launch cam_name:=<your_cam_calib_file_name>

Notes

Overlay Workspace Naming

The overlay workspace is called /home/svo_ws instead of svo_install_overlay_ws like specified in the installation guide for SVO.

Running with Specified Hostnames, Master URIs, and IP

Simply pass in the relevant environment variables using the -e flag!

1567668713694

# For example, for a custom ROS_MASTER_URI:
docker run -it --rm -e ROS_MASTER_URI=RAWR ros:svo
echo $ROS_MASTER_URI
                            .     .
                         .  |\-^-/|  .    
                        /| } O.=.O { |\

Yeah! Buy the DRAGON a COFFEE!

Or leave a tip! γƒΎ(Β°βˆ‡Β°*)

You can’t perform that action at this time.