(We thank the Mars Society India for making this article)
ROS (Robot Operating System) is a collection of various software tools or frameworks which help in developing the “brain” (or logical part) of the robot, and provides operation system like functionality to the developer.
Why use ROS for developing software interfaces for robots ?
ROS provides functionalities like hardware abstraction, clustered computing, robot visualization, sensor interfaces and device drivers, which all form a basis vector towards controlling and describing your robot. Thinking of this in the most abstract terms, imagine you want to describe a robot using code and would hence need to define all it's actions. It is supposed to react in a certain way when the sensor throws a certain reading, navigate in a certain manner suggested by a heavy algorithm running in the background, by using feedback inputs etc., and all this when maintaining the basic purposes of the robot. You can definitely not do all of this using if-else-if conditions, as you might have guessed, given the large complexity of the operations. A great way to approach this would be using interrupts, as is used in processors. But if you have even a slight idea of how interrupts are implemented in hardware and code, you will realise that using interrupts would mean that a major portion of the effort would go in writing basic code, rather than designing and implementing real features for the robot. This is where ROS comes in. The basic idea behind ROS is to abstract the interactions between various components and make message sharing more efficient. What this also means is that you can now have two different teams working on different parts of the robot code, with barely any interaction, and merge their codes seamlessly. ROS achieves this through the publisher-subscriber framework, which enables easy interfacing. The GUI compatibilities with RViz and Gazebo are also very helpful.
Clustered computing over heterogeneous computers
This is perhaps the biggest feature ROS offers. Using the distributed message system of ROS, You can effortlessly pass messages (href to message section) from one ROS node running on your robot’s micro controller to ROS node running on your base station computer, even though they may not be having the same OS (You may have Raspbian subscribing and a slave Arduino and Ubuntu publishing messages to it, for example). All it requires is usage of Subscribers and Publishers. This feature makes ROS useful for upcoming approaches to robotics like swarm robotics etc.
Bindings over various Languages
Another great thing about ROS is that the interactions are through standard message formats and independent of platforms. So your publisher can be written in Python, and subscriber in C++, and yet they would be able to interact readily. This has made ROS a standard in robot-description tools around the world. This is a list of all robots that use ROS for their basic functioning, and the list is ever-growing. This feature of ROS makes it extremely helpful for description of Hardware Drivers. One can write a C++ code for interfacing with the laser scanner, process the data, and publish to a high level code in Python, for visualization.
ROS uses RViz (Robot Vision) framework for visualization of robots, and it requires a URDF (Unified Robot Description Format) file as an input. One can easily construct the URDF file by importing STL files as meshes, and describing the joint appropriately. The same file can also be used in Gazebo for simulations etc.
Sensor Interfaces in ROS
Sensor Interfacing in ROS is facilitated using different types of messages (eg. LaserScan, Temperature, Fluid Pressure). For example, A Leddar sensor node will publish a LaserScan type of message, which will be visualized in RViz to get information from the Leddar sensor.
Highly Permissive Open Source License
One of the inherent motivation behind the development of ROS in the first place was to support reiteration of code in robotics research and development. ROS has a very permissive open source license (BSD license), allowing reuse in commercial and closed source projects. ROScon is also held annually to discuss new developments and recognize contribution of developers to ROS.
More on Why ROS? - http://www.ros.org/is-ros-for-me/
Although there are not any hard pre-requisite for using ROS, basic C++ and python programming skills may be required to understand the basic codes of tutorials.
ROS can be installed very easily on Ubuntu and Debian distributions, though one may need to compile from source on other distros like Raspbian/Kali. ROS as of now is still experimental on OS X and Windows. So, a linux system is a hard pre-requisite for using ROS.
Various Distributions of ROS
First of all, you need to decide which ROS distribution you will install, and like any other OS, ROS gets periodic updates (Link to various ROS distros). Once you’ve decided which distro to use, you need to check whether you’ll be able to install that distro of ROS on your computer’s OS (like ROS Indigo is not compatible with Ubuntu 16.04).
Installation on Ubuntu
The Installation procedure for Ubuntu systems is pretty straightforward, provided you haven’t held on to any broken packages which are required for ROS. ROS (Indigo distro) is extremely sensitive to the version of
libboost installed, and playing around with it is not a good idea. Upgrading your
libboost versions to run other programs will cause ROS Indigo to uninstall. The dependency however, seems to be resolved with advent of ROS Kinetic, which uses shared pointers from
C++11 instead of
- Link for Ubuntu Installation of ROS:
- Link for ROS Indigo http://wiki.ros.org/indigo/Installation/Ubuntu
Installation of ROS Indigo on RPi
Official ARM ubuntu images are available for RPi2, and following standard procedure for ARM based installation (ROS on Ubuntu ARM) is suggested. For RPi2, third party ROS integrated images are also available. For RPi3, currently, there is no official image of Ubuntu available, so one needs to install from source. Also, if you have Raspbian on RPi2 you need to follow the instructions below.
The ROSberryPi link is quite detailed for installation of Indigo version, one needs to do a git hard reset to commit 511d48f, for installation of liburdf-dom, which is not there in the steps mentioned. Be sure to apply the patches for collada_urdf and rviz, because without them, the installation will halt midway. Also, since RPi has limited RAM, you can't build 4 packages at one go (the usual practice with catkin_make), so either you could increase swap space on RPi, or use -j1 argument to limit one package at a time. The process, thus can be very slow and take a lot of time, so it is advised to do it when you have some time at disposal.
Installation of ROS Kinetic on RPi
Source installation of ROS Indigo on RPi is convoluted due to patching and git resets done to retrofit libraries made for Kinetic to run for Indigo. The reason is that in ROS Indigo, shared pointers are imported from Boost, whereas in ROS Kinetic, shared pointers are imported from C++11. Thus, installation of ROS kinetic on RPi 2 and RPi 3 is thus much simpler. The ROSberryPi Link covers all details about the same, as well as some different strategies like using Ubuntu Mate for easier installation etc.
- Official ROS tutorials : One stop guide to *almost* everything in ROS
- Clearpath Robotics ROS tutorials : This is a very good source to learn the bare minimum ROS required to make your own robot, and visualize it on ROS. You can also play around with their Husky Robot to learn a great deal about robot visualization on RViz and Gazebo.
- ROS 101 tutorials by Robohub : Really good for beginners
- A Gentle Introduction to ROS by Jason Kane
- "ROS by example" by Patrick Goebel
As is evident from the intricacy of the ROS structure, it can get very tricky to start off and hang on to the software.
Getting Used to ROS
However, ROS can get sometimes tricky for beginners to understand and comprehend, and unluckily the solution lies in going ahead and actually trying out stuff on your own (instead of reading the code too much in depth and understanding every small nitty-gritty), and gradually (while making small mistakes here and there) one gets comfortable with it. Having an idea about ROS File System is also very necessary, since it helps debug a lot of common errors which occur when you try to import something in your program.
Publishing and Subscribing to a ROS topic via Arduino
Since Arduino is used many times as a slave microcontroller, and as it also supports Analog input functionality which many microcontrollers (including RPi) lack, it is more convenient to interface hardware with arduino, and use Rosserial_arduino library to publish and subscribe to a ROS topic.
But, to achieve this the library runs TCP like server over USB connection, which gives a time lag to data. Thus, this procedure should be used to debug the logic written for hardware, and to get rid of this lag, one can directly use GPIO pins of your microcontroller, and if the microcontroller lacks analog read functionality, one could use SPI/I2C to interface with an ADC to your microcontroller.
Shortcomings of URDF file
For visualizing your robot on RViz, you need to make a URDF (Unified Robot Description Format) file. However, since URDF has joints in a parent child manner, you can’t have a feedback system implemented via URDF (eg. feedback suspension systems like Differential Suspension). The links are hierarchical and hence you may not be able to implement a graph which has a loop.