Skip to content

Understanding ROS Architecture

Chandra Gummaluru edited this page Feb 2, 2020 · 11 revisions

Understanding ROS Architecture

In this part of the tutorial, you will understand how the ROS architecture works.

Note: Make sure you are comfortable creating and building ROS packages.

Nodes

A node is essentially an executable file within a ROS package.

Client Libraries

Each node uses a ROS client library to communicate with other nodes.

These client libraries allow for nodes to be written in different languages. ROS currently supports

Node Types

Nodes can be of one of the following two types:

The roscore Node

The roscore node is a special node responsible for managing other nodes. This is always the first node you should run, which you can do using

roscore

Using rosnode

The rosnode tool can be used to display information about the ROS nodes.

We can see which nodes are currently running using

rosnode list

Note: Assuming you haven't run any other nodes, you should see that just rosout is running. This node is always running as it collects and logs nodes' debugging output.

We can get specific information about a node by using

rosnode info <node_name>

Using rosrun

The rosrun tool can be used to run a node within a package (without having to know the package path).

rosrun <package_name> <node_name>

Using roslaunch

The roslaunch tool can be used to run multiple nodes (specified in a launch file) via a single command.

roslaunch <package> <launch_file_name>

Launch Files

A launch file is an XML file defined with a <launch> tag, and contains a list of nodes that should be run.

Launch files are typically stored within the so-called launch directory of each package.

Within a package, we can create a launch directory using

mkdir launch

Note: The directory to store launch files doesn't necessarily have to be named launch. In fact you don't even need to store them in a directory.

roslaunch automatically looks into the passed package and detects available launch files. However, this is considered good practice.

Each node to run is specified using a <node> tag.

<node pkg="package_name" name="node_name" type="node_type"/>

Note: In the <node> tag, the type field indicates which node should be launched, while the name field is any arbitrary (but unique) string which you can use to refer to that specific node.

Sometimes, it is useful to group nodes together, which can be done using the <group> tag.

<group ns = "group_namespace">
  ...
</group>

Note: In the <group> tag, the ns field is any arbitrary (but unique) string which you can use to refer to that group. Nodes within a group must contain unique names.

The rqt package contains several tools for visualizing and debugging the system.

Note: The rqt package, which is not installed as part of the default set. To install it, run

sudo apt-get install ros-<distribution>-rqt
sudo apt-get install ros-<distribution>-rqt-common-plugins

The rqt_graph tool can be used to show a dynamic graph of the communication between nodes in the system.

rosrun rqt_graph rqt_graph

The rqt_console attaches to the ROS logging framework to display output from nodes.

rosrun rqt_console rqt_console

The rqt_logger_level allows us to change the verbosity level (DEBUG, WARN, INFO, and ERROR) of nodes as they run.

rosrun rqt_logger_level rqt_logger_level

Next Steps

You should now have a basic understanding of programming within ROS. However, it should be noted that we have barely scratched the surface on everything ROS has to offer. If you wish to learn more, we have provided a few additional resources below.

Additional Resources

If you are looking to learn ROS in-depth from scratch, we suggest reading A Gentle Introduction to ROS by Jason M. O'Kane.

For additional ROS documentation, check out of the official ROS Wiki.

Clone this wiki locally