Usually, when we talk about robotics, the first thing that flashes into mind is robotic manipulators equipped with end-effectors, driven by actuators, guided by sensors, and controlled by microcontrollers. The mechanical hardware always impresses viewers, but it is the robotic software underneath, that brings these magnificent machines to life. Most of the small robots are programmed from scratch, which can be tedious when a robotic application is large or multifaceted. In software development, large software applications are managed with the help of a software development kit. Similarly, the development of extensive robotic software requires a framework—Robot Operating System (ROS) is an open-source initiative that provides that framework.
Despite its name, ROS is not an operating system. It is a software framework for developing robotic software that includes a set of different tools and libraries useful in developing robotic applications. Since its inception, ROS has been tuned to work on Ubuntu Linux. Most developer tools, drivers, libraries, and algorithms have been designed to operate in Unix-like systems. Still, many ROS libraries and developer tools can be used on Mac OSX and Microsoft Windows. Ubuntu has been a natural choice for ROS because the framework mainly relies on open-source dependencies.
In this article, we will define the Robot Operating System (ROS), how it works, and why it is useful.
What is ROS?
The RO software development framework is an open-source project started in 2007 at Stanford University under the title “Switchyard”. In 2008, the project was undertaken by a start-up, Willow Garage. In 2013, Willow Garage formed Open Source Robotic Foundation (OSRF) and made ROS an open-source project.
Robotics involves control theory, computer vision, machine learning, embedded electronics, and artificial intelligence. Robot applications are complex software involving multiple disciplines. ROS organizes a robotic application into packages and provides a hardware abstraction layer allowing develop robotic software irrespective of the underlying hardware. The framework also provides a message-passing middleware where robotic data can be communicated among different processes and even other machines. Being a flexible framework, ROS can program any robotic functionality. The most significant advantage of ROS is that ROS applications with all possible robotic functionalities can run on any robot, irrespective of its hardware components.
Why ROS?
There was a great void for a generic robotic software framework. ROS filled that gap and presented a modular, platform-independent approach to robot application development. Because it is free and open-source, anyone can use, modify, debug and contribute to ROS. It can also be used in any industrial application without any license fees. Many universities are actively involved in robotic research involving ROS. Being a community-driven project, ROS is continuously growing and evolving, and community support ensures ROS is bug-free, robust, and inclusive of all emerging capabilities and functionalities.
The framework supports popular programming languages, including C, Python, Java, and Lisp. It already has an interface to several third-party libraries, including Open-CV, Open-NI, OpenRAVE, and PCL. The ROS packages operate on a hardware abstraction layer, so the platform-independent ROS and its packages can be used for any hardware. Because it is very flexible, developers can customize it, and choose which components of the ROS framework to incorporate in a robotic project and which libraries they wish to interface.
ROS lets engineers quickly build, test, and deploy agnostic robotic software that can be reused on any other robot. ROS is integrated into open-source simulators like Gazebo and other proprietary simulators, including V-REP. The ROS code can be easily tested using a built-in framework called “rostest”. The application code remains modular, well-organized, reusable, scalable, and hardware-independent.
How ROS works
A ROS application is organized into meta-packages—a collection of packages for specific functionality. For example, a mobile robot may have a meta-package handling navigation system. The packages are the building blocks of any ROS software and consist of nodes/processes associated with datasets and configuration files. A node is simply a process that uses ROS API to communicate within the robotic system and is created with the help of client libraries. Robotic software in ROS is a collection of nodes where each node is responsible for a specific function. For instance, one node may be responsible for navigation, another may be responsible for collecting sensor data, and another may be responsible for hardware interfacing.
A ROS application, therefore, can be considered a collection of nodes. These nodes must communicate with each other and exchange data or render services for robotic functioning. There’s an intermediate node called ROS Master that connects all the nodes and establishes data communication among them. The variables used in data communication are stored in a parameter server attached to the ROS master. Each variable has a scope and may be accessible by one or more nodes.
The data is communicated between nodes in the form of ROS messages. There are two ways of communicating messages between nodes— topics and services. Topics are a publish-subscribe method of transmitting data between nodes and are named buses to which nodes can register as publisher or subscriber. When a node publishes a ROS message on a topic, it is sent to the ROS master. The nodes registered as subscriber to the same topic receive the publisher URI from the ROS master and thus receive the message from the publisher as soon it is published. Once the nodes are connected peer-to-peer, the ROS master has no further role to play. The nodes can communicate ROS messages peer-to-peer with each other without passing through the ROS master. This is somewhat similar to the MQTT protocol, except that the messages are always passed between nodes through the broker in MQTT. Here, the role of the ROS master is done once it connects all nodes peer-to-peer.
Services are a request-response method of communicating ROS messages between nodes. A node requests data from another node. The other node act as a service provider running a service routine. On receiving a request from another node, it runs the service routine and transfers results using ROS messages. The ROS messages on a node are stored in message files having a .msg extension. The service definitions on a node are stored in service files having .srv extension. There is a manifest file called package.xml within the application that stores all information regarding the application name, version, author, required packages, and dependencies.
ROS includes utilities called “Bags” that record and playback ROS messages and are useful in simulating and inspecting robotic data.
ROS distributions
ROS distributions are a versioned collection of ROS packages. These are similar to Linux distributions. Each distribution consists of some core packages whose stable versions are maintained till the end of the life of the distribution. The ROS distributions are assembled with compatibility with Ubuntu Linux. The versioning of ROS distributions is also done concurrently with Ubuntu Linux versions because ROS distributions mostly have open-source dependencies that work and rely on Linux. Here, you can find documentation for some of the active ROS1 and ROS2 distributions.
It should be noted that ROS Noeitc Ninjemys is the final release of ROS1. Future releases of ROS distributions will be based on ROS2. If you you are neither looking for new capabilities nor significant updates, you can use the previous long-term support (LTS) distribution, which is ROS Melodic Morenia at this time. If you are looking for new capabilities as well as are comfortable with major updates, use the latest LTS, i.e., ROS Noeitc Ninjemys.
Client libraries
The ROS client libraries are used to write ROS nodes. With the help of client libraries, you do not need to write code from scratch; instead, you need to define service callbacks and implement publish-subscribe for the node. The client libraries are available per programming language: roscpp is the client library for writing nodes in C++; rospy is the client library for writing nodes in Python; and roslisp is the client library for writing nodes in LISP.
ROS tools
ROS distributions include various valuable tools for solving common development problems and automating complex tasks like simulating and visualizing robotic data. The tools may be GUI or command-line tools. These are included within packages. Some of the popular ROS tools involve the following.
RVIZ: This is a 3D visualizer helpful in creating visual graphs of 2D and 3D values accessed from robotic data. It helps visualize robot models, image data, point clouds, and sensor data.
rosbag and rqt_bag: This is a command-line tool to record and play back ROS messages. It is useful in debugging applications and operates as a command-line console. Another tool, rqt_bag, provides a graphic interface to rosbag.
rqt_plot: This tool is helpful for live plotting scalar values published to ROS topics.
rqt_graph: This tool helps visualize nodes/processes running in ROS and the interconnections between them.
Webviz: This is a web-based valuable tool for visualizing ROS data and ROS bag files.
Foxglove Studio: Available as both a web and desktop application, this is an integrated development environment (IDE) for visualizing and debugging ROS data.
ROS Mobile: This Android application is useful for the dynamic control and visualization of ROS-based mobile robots.
Command-line tools: Several command-line tools are available, from installing ROS to running and debugging ROS. The tools rosmake, rosinstall, roslocate, rosdep, rospack/roscd, and rosstack/roscd are used while installing ROS. The tools roslauch, rosrun, and roscore are used for running ROS. The tools rostopic, rosservice, rosnode, rosparam, rosmsg, rossrv, and roswtf are used for interacting and debugging ROS.
ROS simulator
ROS is integrated with the open-source robotic simulator Gazebo. Gazebo, which can be integrated with ROS using a plugin, is capable of simulating a variety of robot models and includes support for a large number of sensors. Proprietary simulators like Webots and V-REP also support ROS. However, you need to pay a license fee to use them. If you do not want to pay for robotic simulation, Gazebo is enough to maintain ROS compatibility.
ROS nodes
Nodes are the building blocks of ROS application. The application is divided into packages. For example, a mobile robot application may be divided into three packages—camera, navigation, and hardware control. Each package may contain one or more nodes, although each package contains only one node normally. The camera package could include nodes such as the camera driver and image processing. It is possible to keep image processing in a different package. The navigation package may consist of nodes for motion planning and path correction. The hardware control package may include nodes for the main control loop, robot state publishing, and hardware drivers. The nodes interact with each other through topics and services, communicating necessary data for robotic functions. For example, the nodes for motion planning and path correction will exchange data with the main control loop node in the hardware control package to enable navigating the robot. Some standard functionalities in robotics include navigation, perception, mapping and localization, data logging, visualization, and hardware control.
ROS hardware
There is extensive hardware support for ROS. Many sensors, including 1D range finder, 2D range finder, 3D sensors, cameras, motion capture, force/torque, RFID, input/output, speed, touch, pose estimation, and environmental sensors, are supported by ROS. You can find a complete listing of ROS-supported sensors here. A list of supported motor drivers is available on this link. If you want to learn about some featured robots running on ROS, click here.
ROS versions
Presently, two active major ROS versions exist—ROS1 and ROS2. The ROS Noeitc Ninjemys was the final release of ROS1. A new version of ROS2 is released every six months and is supported for a year. You can browse through the latest ROS distributions here. Note that ROS distributions are installed on Ubuntu Linux or other supported operating systems using command-line tools.
Getting started with ROS
You can start with ROS on any Linux computer, Windows, or Mac. Many robotic applications can be written and tested with the help of the ROS simulator. For real-life implementation, you will need specific hardware components per the automated application. For example, you may need Arduino, motors, motor drivers, and sensors to build a mobile robot, or you may need a camera module for face detection or other capabilities.
You may also like:
Filed Under: What Is
Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.