[ROS in 5 mins] 005 – What is a ROS Node?

Written by Bayode Aderinola

19/05/2018

Hello ROS Developers! In this post, we’ll see what a ROS node is in just 5 minutes! We’ll see how to launch a ROS node, what a ROS node does and some commands to get basic and extended information about ROS nodes.

Let’s go!

Step 1: Setup your development environment

To follow this post, you need a computer with ROS already installed. There are three options; I recommend the last one as it’s the easiest!

  1. You have ROS installed locally (kinetic <=  version < crystal). Great, nothing more is needed, just be ready to spin up a terminal at short notice 🙂 .
  2. You don’t have ROS installed but you have installed docker . Don’t worry, there’s a way out – run docker run -it osrf/ros:kinetic-destop in your terminal to pull a ROS docker image. Please note:
    • Docker will “pull” this image if you don’t have it locally already.
    • You need to run this command on every terminal you use in this post, before typing any other command!
  3. Neither ROS nor docker is installed? No problem – launch a ready-to-go development environment on ROS Development Studio (ROSDS) within your browser! If you don’t have an account yet, you can create a free account here. Once you log in, create a project and call it rosnode_test. In your project configuration, select Ubuntu 16.04 + ROS Kinetic + Gazebo 7. To “open a terminal”, pick the Shell app from the Tools menu.

Step 2: Run some commands to learn about ROS nodes

Open a terminal and run the following command to start roscore:

user:~$ roscore
... logging to /home/user/.ros/log/34f74d7a-4482-11e9-b7ad-06484a70109a/roslaunch-ip-172-31-44-254-32219.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://instance:35586/
ros_comm version 1.12.14


SUMMARY
========

PARAMETERS
 * /rosdistro: kinetic
 * /rosversion: 1.12.14

NODES

auto-starting new master
process[master]: started with pid [32244]
ROS_MASTER_URI=http://instance:11311/

setting /run_id to 34f74d7a-4482-11e9-b7ad-06484a70109a
process[rosout-1]: started with pid [32273]
started core service [/rosout]

(roscore gets the ROS system started and ready to work. You can read more about it here)

Looking at the output of the command we ran above, you’ll find a section labeled NODES, and under it you’ll see the phrase started core service [/rosout]. Back up there and run the command shown below in a new terminal!

user:~$ rosnode list
/rosout

The list command shows the list of ROS nodes currently running. Now let’s get some information about the single node shown, in the same terminal:

user:~$ rosnode info /rosout
--------------------------------------------------------------------------------
Node [/rosout]
Publications:
 * /rosout_agg [rosgraph_msgs/Log]

Subscriptions:
 * /rosout [unknown type]

Services:
 * /rosout/get_loggers
 * /rosout/set_logger_level


contacting node http://instance:42806/ ...
Pid: 32273

From the output of this program we can see that node /rosout publishes to topic /rosout_agg, subscribes to topic /rosout and provides services /rosout/get_loggers and /rosout/set_logger_level.Quite some work, you might say.  In future posts we’ll learn about ROS topics, publishers, subscribers and services, but we need to get the concept of nodes now because it’s a the root of them all.

And we’re all done for this section!

Step 3: Master the concept – what is a ROS node?

You might already know it, but the output of the programs in the section above were blaring it from the speakers 🙂 .

To use the words from ROS wiki, a node is a [computer] process that performs computation. Let’s break that down:

  • A computer process…: yes, as you can see from the output of the roscore commands, two computer processes were started.
  • …that performs computation: yes, but not necessarily math! We saw that node rosout performs quite a bit of work; that’s the “computation” we’re talking about here. There was another node there, master (http://wiki.ros.org/Master). Though not listed in the list of nodes, it also “performs computation” by providing naming and registration services for other nodes.

That’s basically it! If you’ll like more theory, read more about ROS nodes at http://wiki.ros.org/Nodes.

Bonus: Video

Prefer to see the ‘sights and sounds’ version of this post? The video below is for you. Please tell us what you think about it.

Feedback

Did you like this post? Whatever the case, please leave a comment on the comments section below, so we can interact and learn from each other.

If you want to learn about other ROS topics, please let us know on the comments area and we will do a post/video about it.

Thank you!

Masterclass 2023 batch2 blog banner

Check Out These Related Posts

129. ros2ai

129. ros2ai

I would like to dedicate this episode to all the ROS Developers who believe that ChatGPT or...

read more

0 Comments

Submit a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Pin It on Pinterest

Share This