Introduction to Robotics Operating System (ROS)

The Robotics Operating System is a flexible framework for writing software for robots. In this guide, you’ll learn about the ROS architecture, including nodes, topics, messages, services, actions, and packages.

Brien Posey

August 6, 2024

4 Min Read
animated robotic arm and the text getting started with robotic operating system (ROS)

The Robotics Operating System, or ROS (pronounced “Roz”), is a popular platform for building open-source robotic projects.

Despite its name, ROS is not a traditional operating system, although it does provide some operating system-like features. Like Windows or Linux operating systems, ROS acts as a hardware abstraction layer, allowing robotics code to work with different hardware platforms. In my organization, for example, I run ROS on various platforms, including the Raspberry Pi and Jetson Nano.

Just as ROS is compatible with various hardware platforms, it also works with several different programming languages. Python is by far the most popular choice for writing ROS applications, but C++ is also widely used.

The key to successfully developing ROS-based robotics is to understand the ROS architecture. There are several high-level components forming the foundation of all ROS projects.

The most basic building block in ROS is a node. Every ROS application contains at least one node, though it’s common for projects to include multiple nodes. Each node performs a specific task. For instance, if a robot has a laser scaler (a device using lasers to measure distance), a node would typically be associated with that hardware. Similarly, if a robot has wheels, there would likely be a node for the wheels or even separate nodes for each wheel. In my current project, I am building a robot with tracks (like a tank) instead of wheels. Since the two tracks move independently, each will have a separate node.

Related:New AI Technique Lets Robots "Think" Before They Perform Complex Tasks

The next crucial ROS element is a topic, essentially a named communications bus between nodes. To understand how topics work, consider the earlier example of a robot equipped with wheels and a laser scaler. For simplicity, imagine that a single node controls all the wheels. Furthermore, we need the robot to drive in a straight line until it is within 12 inches of a wall.

The problem here is that although the robot has the necessary hardware, the laser scaler and the wheels are controlled by different nodes. As such, the wheel node doesn’t know how far the robot is from the wall.

Here is where topics come in. A topic enables these nodes to communicate by providing a named channel for message exchange.

Messages are the data structure used to transmit information between topics. The data in these messages must be in a standardized format that both sending and receiving nodes can understand.

In our example, the laser scaler node might send messages to the wheel node indicating the distance to the nearest wall. However, this distance must be communicated in a way both nodes understand. For instance, if the laser scaler node sends a value of 15, the wheel node needs to know whether this represents 15 feet, 15 inches, or another unit of measurement.

Related:Getting Started With HoloLens 2 App Development

This requirement brings up an important concept: Most nodes in ROS have a publisher/subscriber relationship. In our example, the laser scaler node acts as the publisher because it collects sensor data and sends (publishes) the data across a topic. The wheel node is the subscriber because it receives data from the publisher node. While there is often a one-to-one relationship between publishers and subscribers, you can easily create one-to-many relationships where one publisher sends data to many subscribers.

Robotic_Operating_System_(ROS)_Key_Terminology.png

Occasionally, a situation arises where a publisher sends data to a subscriber and needs a response. For example, the laser scaler node might want to know if the wheels have stopped when the robot gets close to the wall. In such cases, we use services. A service is similar to messages but involves a pair of messages: one sent out (request) and one received (response).

For situations that require ongoing communication, we generally use actions instead of services. An action is similar to a service but is designed for longer-duration tasks.

One final fundamental aspect of ROS is the concept of a package. When you create a ROS project, all the elements that make up the project are organized in a package. A ROS package contains everything your robot needs to function, such as nodes, the scripts associated with those nodes, data files, configuration files, and any other necessary components.

Stay tuned for more ROS insight. This month, we'll provide step-by-step instructions for deploying ROS and building your first ROS application.

About the Author

Brien Posey

Brien Posey is a bestselling technology author, a speaker, and a 20X Microsoft MVP. In addition to his ongoing work in IT, Posey has spent the last several years training as a commercial astronaut candidate in preparation to fly on a mission to study polar mesospheric clouds from space.

https://brienposey.com/

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like