The Building Blocks of ROS

How the Robot Operating System (ROS) powers tomorrow’s robots

Esther Weon 5 min read
Published May 25, 2021

Note: The concepts and CLI commands covered in this post are applicable across ROS 1 and 2. With that said, newer versions of ROS 1 and ROS 2 have integrated several packages (e.g. rqt_console, rqt_graph, rqt_plot, etc.) as plugins into a parent rqt package. For the purposes of this post (i.e. covering different features in discrete steps), we've opted to use the older, but still supported, version of these CLI commands (e.g. rosrun rqt_graph rqt_graph vs. rqt). Check out the rqt docs for more information.

If you’ve kept up-to-date on tech’s latest robotics projects or tinkered around with your own robot kit, you’ve probably come across mentions of ROS.

At its core, the Robot Operating System (ROS) is an open-source software suite built to simplify robotics development. It provides a collection of tools that runs everything from low-level device control, hardware abstractions, and package management. Due to its distributed design, users can pick and choose what parts of ROS to integrate into their own projects.

ROS was born in 2007, out of roboticists’ desire to more easily share resources and build upon each other’s work. These experts experienced firsthand how difficult it was building software for an increasingly diverse array of robots across a variety of platforms, and realized that no one person was equipped to tackle the field’s challenges alone. They hoped a deliberately modular framework like ROS would foster more collaborative robotics development and encourage code reuse among the community’s brightest minds.

Nearly 15 years after its conception, the ROS ecosystem now consists of tens of thousands of users worldwide, with applications ranging from COVID-19 disinfection robots to humanoid robotic hands. Its members have contributed cutting-edge libraries like map generation systems, navigation tools, and computer vision utilities, ensuring ROS’s continued relevance in the robotics world.

Basic concepts

ROS is a distributed framework of self-contained processes, or nodes, that discover and communicate with each other at runtime. Any given robot can have multiple nodes, each of which owns a subset of the robot’s tasks – one node may keep track of the robot’s velocity, another its steering angle, and still another its camera feed. All nodes are registered with the ROS master, a service registry that helps nodes locate each other.

Nodes communicate with each other by publishing or subscribing to messages on different channels of information, called topics. In this way, we can separate concerns into their respective nodes, while still empowering the robot to make complex decisions to execute a task. Nodes can be grouped into packages, which can then be easily shared and distributed among ROS users.

ROS nodes

Messages for a topic adhere to a fixed schema, called a message type. For example, one topic can contain messages with just position coordinates (geometry_msgs/Point), another lidar point cloud data (sensor_msgs/PointCloud), and still another text logs (std_msgs/String).

A message type is defined via multiple fields, each with a specified type. For example, the geometry_msgs/Pose message type consists of a position and orientation field, each of which have their own message type definitions:

message types

In summary, if nodes are like walkie-talkies that can communicate with each other, then topics are the channels that they broadcast audio on, and messages are the words that travel across these channels. In the same way that certain walkie-talkie channels are reserved for specific types of communication, each ROS topic is also reserved for messages that adhere to a specific type.

Useful commands

To get started using ROS, you will need to install it on your machine – ROS officially supports only Ubuntu, but you can get set up on Windows (Windows Subsystem for Linux) and MacOS (Docker for Mac) as well.

Before running any nodes, you must run roscore to spin up the following components:

  • ROS master – Service registry that helps nodes locate each other.
  • rosout – Logger for nodes' debugging output.
  • Parameter server – Server that allows nodes to store and retrieve parameters at runtime.

roscore

Now that you have your core ROS system up, you can use rosrun to find ROS packages that contain nodes you want to run.

For example, rosrun turtlesim turtlesim_node will find the turtlesim ROS package and run its turtlesim_node to bring up a simulation of swimming turtles on your desktop. Running rosrun rqt_graph rqt_graph will run that package’s rqt_graph node to render a graph of your nodes connected by their publications and subscriptions.

Once you have a few nodes from different packages running, use rosnode to display information about your currently active nodes.

  • rosnode list – Lists current nodes.
  • rosnode info /your_node_name – Provides more information about a given node, including publications and subscriptions.

Once you have several nodes running, use rostopic to fetch information for any published topic.

  • rostopic echo /your_topic – Displays messages published to a given topic.
  • rostopic list – Prints information about active topics.
  • rostopic type /your_topic – Returns the message type for a topic.
  • rostopic pub /your_topic package_name/MessageType [args] – Publishes data to a given topic with a specified message type.

Finally, use rosmsg to inspect messages and their types in more detail.

  • rosmsg list – Lists all message types.
  • rosmsg show package_name/MessageType – Displays the fields for a given message type.

Useful packages

Given how extensive the ROS package environment is, it is easy to get overwhelmed by the selection. Here are a few popular packages that you can get started with:

  • rqt_console – Provides a GUI for displaying and filtering ROS messages.
  • rqt_graph – Visualizes the ROS computation graph – i.e. nodes and the topics they publish and subscribe to.
  • rqt_image_view – Displays camera images using image_transport.
  • rqt_plot – Plots numeric values on a 2D chart.

How Foxglove Studio fits in

While the ROS ecosystem offers an impressive array of features and services, it can be overwhelming to find, install, and run them all at once. ROS is also tightly bound to specific versions of Ubuntu, which introduces significant overhead for users interested in quickly viewing their data.

Studio has integrated many of ROS's visualization and debugging tools into one cross-platform desktop application, so that instead of memorizing package names and CLI commands, you can simply drag and drop a panel from our menu into your layout to start seeing results. For example, we've incorporated features similar to rqt_console, rqt_graph, rqt_image_view, and rqt_plot, into our Raw Messages, Topic Graph, Image, and Plot panels, respectively.

Studio further streamlines visualization and debugging workflows by allowing users to load .bag files directly into the app – you no longer need to run roscore and rosbag in multiple terminals every time you want to inspect your data.

Studio panels vs ROS tools

We’re currently working to support user contributions to an extensions library, which will allow you to write your own custom plugins, build project-specific panels, and ultimately customize every aspect of your Studio development workflow.

To learn more about how Foxglove Studio can accelerate your robotics development, feel free to check out our docs or reach out to us directly in our Slack community.

Get blog posts sent directly to your inbox.