I spent today learning about ROS and how to process ROS bag files.
Even though the data for the Didi challenge was released on the 22nd of March, I was not able to view it until yesterday, due to a painfully slow internet connection. The data was 32Gb, which tipped me over my download limit for the month, resulting in the download rates being capped to 20kb/s.
I was expecting the data to be like the
Kitti raw dataset
as was claimed by the description for the Didi challenge. However, the file
structure of the data is completely different. It is composed of *.bag
files,
which i have learnt are files used by the Robot Operating System (ROS).
So today I spent my time installing ROS (which took forever on a 20kb/s connection). And learning how to process ROS bag files.
The Didi challenge rules state that the submissions must be compatible with an Ubuntu 14.04 + ROS Indigo platform. My operating system is already based on Ubuntu 14.04, so I followed the instructions for installing the Indigo version of ROS from the ROS wiki, which can be condensed to the following:
# INSTALL ROS INDIGO - in ubuntu 14.04 # ADD TO APT REPOSITORY LIST sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu trusty main" > /etc/apt/sources.list.d/ros-latest.list' # SETUP KEYS sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116 # UPDATE APT PACKAGE LIST sudo apt-get update # INSTALL THE DESKTOP FULL VERSION sudo apt-get install ros-indigo-desktop-full # BARE BONES VERSION - NO GUI # sudo apt-get install ros-indigo-ros-base # INITIALIZE ROSDEP sudo rosdep init rosdep update # ENVIRONMENT SETUP echo "source /opt/ros/indigo/setup.bash" >> ~/.bashrc source ~/.bashrc # GET ROSINSTALL sudo apt-get install python-rosinstall
The next step was ensuring that the installation was succesful, by checking that
the ROS_ROOT
and ROS_PACKAGE_PATH
environment paths actually exist. This was
checked using the following command.
printenv | grep ROS
Once that was confirmed, it was a matter of configuring ROS on my system, which involved using the following steps from the ROS wiki
# SOURCING ENVIRONMENT - for indigo version source /opt/ros/indigo/setup.bash # CREATING A ROS CATKIN WORKSPACE mkdir -p ~/catkin_ws/src cd ~/catkin_ws/ catkin_make # SOURCING CATKIN ENVIRONMENT - and automatically get it to source from now on echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc source ~/catkin_ws/devel/setup.bash
Once again, it was important to check that this configuration was succesful by
checking that the newly created catkin workspace was included in the environment
path for ROS_PACKAGE_PATH
. This was checked by running the following command:
echo $ROS_PACKAGE_PATH
Which should return something like:
/home/youruser/catkin_ws/src:/opt/ros/kinetic/share
In order to get an idea of both ROS and the data for the Didi Challenge, i made use of the instructions in this Github post to visualize the data.
Following the steps on there gave a visualization like the following (Gif courtesy of Giovanni Claudio):
But after running this, it was not in the slightest bit clear to me how this is useful for processing the data. So I decided to attempt something that would feel more familiar, by looking at the python API.
When ROS is installed, there is a python package that is automatically added
called rospy
. If you use the default version of python on your system then it
can just be imported from within your python shell using:
import rospy
However, I had set up a virtualenv without using the --system-site-packages
option. So it did not make use of any of the global python libraries installed
on the root python installation. So I needed to create pointers from my
virtualenv to rospy libraries within the the dist-packages
directory in the
root python directory.
At first I tried creating a link to rospy
, but then i found out that it
depended on another library. So i linked to that one too, and another one, and
another one. Soon i had a very long list of libraries that i was manually
linking to and still had no idea how many more i would have to go.
So i decided on another approach. I decided to learn how to upadte a virtualenv
so that it would act as if it was initialised with the --system-site-packages
.
It turns out there is a file that acts like a switch, bewtween inheriting, and not inheriting libraries from the root installation. This file is:
/path/to/my/virtualenv/lib/python2.7/no-global-site-packages.txt
If it is present, then none of the installed libraries from the global python install are inherited. So, in order to inherit them, it is just a matter of deleting this file.
After doing this, I had access to rospy from my virtualenv.
After having rospy
set up, it was a matter of probing what could be done with
it.
Following the Python API documentation was completely fruitless. It didnt give me any insight into how I could read the Didi challenge data. This rosbag cookbook however was a little more helpful. I was able to modify some of the sample code on there to probe some information about the Didi data.
from __future__ import print_function import os import yaml from rosbag.bag import Bag data_dir = "/path/to/didi_data" # Change this to the path in your computer bag_name = 'approach_1.bag' # Change to the desired ros bag bag_file = os.path.join(bag_file_dir, bag_file_name) info_dict = yaml.load(Bag(bag_file, 'r')._get_yaml_info()) # Print the information contained in the info_dict info_dict.keys() for topic in info_dict["topics"]: print("-"*50) for k,v in topic.items(): print(k.ljust(20), v)
Which prints out the following:
-------------------------------------------------- topic /cloud_nodelet/parameter_descriptions type dynamic_reconfigure/ConfigDescription messages 1 -------------------------------------------------- topic /cloud_nodelet/parameter_updates type dynamic_reconfigure/Config messages 1 -------------------------------------------------- topic /diagnostics connections 3 frequency 75.7368 messages 77 type diagnostic_msgs/DiagnosticArray -------------------------------------------------- topic /diagnostics_agg connections 2 frequency 1.9999 messages 23 type diagnostic_msgs/DiagnosticArray -------------------------------------------------- topic /diagnostics_toplevel_state connections 2 frequency 2.0 messages 23 type diagnostic_msgs/DiagnosticStatus -------------------------------------------------- topic /gps/fix type sensor_msgs/NavSatFix frequency 10.0084 messages 86 -------------------------------------------------- topic /gps/rtkfix type nav_msgs/Odometry frequency 10.0113 messages 112 -------------------------------------------------- topic /gps/time type sensor_msgs/TimeReference frequency 10.0114 messages 106 -------------------------------------------------- topic /image_raw type sensor_msgs/Image frequency 29.9965 messages 333 -------------------------------------------------- topic /obs1/gps/fix type sensor_msgs/NavSatFix frequency 1.0009 messages 11 -------------------------------------------------- topic /obs1/gps/rtkfix type nav_msgs/Odometry frequency 9.9881 messages 111 -------------------------------------------------- topic /obs1/gps/time type sensor_msgs/TimeReference frequency 10.0041 messages 85 -------------------------------------------------- topic /radar/points type sensor_msgs/PointCloud2 frequency 19.999 messages 222 -------------------------------------------------- topic /radar/range type sensor_msgs/Range frequency 20.0016 messages 222 -------------------------------------------------- topic /radar/tracks type radar_driver/RadarTracks frequency 19.9976 messages 222 -------------------------------------------------- topic /rosout connections 7 frequency 29228.5993 messages 15 type rosgraph_msgs/Log -------------------------------------------------- topic /tf type tf2_msgs/TFMessage frequency 99.2946 messages 1100 -------------------------------------------------- topic /velodyne_nodelet_manager/bond connections 3 frequency 31.9959 messages 44 type bond/Status -------------------------------------------------- topic /velodyne_packets type velodyne_msgs/VelodyneScan frequency 9.9908 messages 111 -------------------------------------------------- topic /velodyne_points type sensor_msgs/PointCloud2 frequency 9.9911 messages 110
From what I have been able to gather, a "topic" is like a channel that different components of the robot can subscribe or publish to. Eg, a camera might take frames of images and then publish each frame to a channel dedicated to photos. Other parts of the robot might chose to listen to that channel in order to process the images in some way, which might then be published to another channel for processed images. Other parts of the robot might then be designed to listen to that channel and several other channels to process all the sensory data to make some kind of decision, which might itself be broadcast along another channel. It might be actuators, like a steering wheel controller, or the brake, that listens to that channel, and acts in a certain way depending on the message being broadcast.
So, it seems like the most important channels, or "topics" for the task of predicting 3D bounding boxes of cars in the scene would be the following two:
-------------------------------------------------- topic /image_raw type sensor_msgs/Image frequency 29.9965 messages 333 -------------------------------------------------- topic /velodyne_points type sensor_msgs/PointCloud2 frequency 9.9911 messages 110
I still have absolutely no idea how to actually extract the data from those "topics" in the ROS bags, so learning how to do that will be the next step.
Note you can comment without any login by: