ROS (Robot Operating System) is a popular robotics middleware for all kinds of robotics project. For my final year project with MUR, I will be working on the perception subsystem of the driverless race car. As a team, we have decided to use ROS for developing and managing our software packages. It also works well with Gazebo which is great for simulating our driverless vehicle when we are unable to test on the actual vehicle.

ROS Installation with Docker

For getting ROS up and running in macOS, I referred to this useful tutorial. It was relatively straightforward and I was able to get everything downloaded and running within an hour.

Turtlesim running within macOS Docker

Additional post for getting Gazebo running can be viewed here. Please note that the instructions provided there are to be executed line by line.

I did encounter a small problem when trying to run the last command with x11vnc, but was able to resolve it by not passing -display flag.

$ docker pull gazebo:latest
$ docker run -p 5900:5900 -d -v="/tmp/.gazebo/:/root/.gazebo/" --name=gazebo $ gazebo

$ docker exec -it gazebo bash  # get into the Docker

$ apt-get update
$ apt-get install x11vnc -y
$ apt update
$ apt install xvfb ufw -y
$ Xvfb :1 -screen 0 1600x1200x16 &
$ export DISPLAY=:1.0
$ gzclient &
$ x11vnc

Docker Usage

Here is a small collection of commands which are useful when working with Docker.

$ docker ps --all # list all containers

Notes from Tutorial

The ROS wiki provides a clear and easy to follow tutorial. Below are some of the notes which taken while I was going over the tutorial.

We can use rospack to get information about packages. For example, we can use it to find the path to a particular package.

$ rospack find roscpp

/opt/ros/melodic/share/roscpp

We can use roscd to change directory directly to a package. Note that roscd and other ROS tools will only find ROS package that are within the directories listed in the ROS_PACKAGE_PATH.

$ roscd roscpp
$ pwd
/opt/ros/melodic/share/roscpp

We can use rosls to directly list what is inside the package directory.

$ rosls roscpp_tutorials
cmake  launch  package.xml  srv

It is great that ROS supports tab completion, so most of the time you can press tab to complete an un-ambiguous command. Or you can press TAB twice to list the possible options.

More CLI utilities are described in the rosbash page.

For convenience, we can add to our bashrc to source the ROS commands and environment upon start up. This would differ depending on which ROS distribution you are using. Since I am using the Melodic distro, therefore the command points to the Melodic installation directory.

# add command to source ROS environments
source /opt/ros/melodic/setup.bash

Gragh Concepts in ROS

  • Nodes: executable that uses ROS to communicate with other nodes
  • Messages: ROS data type used for subscribing or publishing ot a topic
  • Topics: Nodes that can publish messages to a topic as well as subscribe to a topic
  • Master: Name service for ROS (helps nodes to find each other)
  • rosout: ROS equivalent of stdout/stderr
  • roscore: Master + rosout + parameter server