What is ROS_MASTER_URI?

Written by Bayode Aderinola

20/03/2019

Hello ROS Developers! In this post, we will see what the ROS_MASTER_URI is in just 5 minutes. We’ll see what it represents and how we use it in the entire ROS system.

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, but I strongly recommend option 3 as it’s the easiest and the only one I can guarantee will work.

  1. You have ROS installed locally, such that kinetic <= version < crystal. Great, nothing more is needed, just be ready to spin up a terminal.
  2. You don’t have ROS installed but you have installed docker… there’s a way out: run docker run -it osrf/ros:kinetic-desktop 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. 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_MASTER_URI

Open a terminal and run any “roslaunch” command. Let’s use the example shown here (should work where you have a full ROS installation, like in the ROS Development Studio):

user:~$ roslaunch openni_launch openni.launch

...

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

...

The output is a very long one, so I have truncated it, leaving only the part we want to examine. You’ll see that part of the output indicated that a master process was started, and then specified the ROS_MASTER_URI. This is because the two are related.

What then is this “ROS master URI”? Let’s learn about that in the next section.

Step 3: Master the concept – what is ROS_MASTER_URI?

As you might have guessed, ROS_MASTER_URI tells us where we can locate the master ROS process. (We learned about this master process in a different post. Here is the link, in case you have not seen it.) It’s the network address of the computer/device on which the ROS master process is running.

Please take note of the following about ROS_MASTER_URI :

  • it’s a required setting, as ROS is a centralized system; all nodes depend on the master for core service and must, therefore, be able to locate it or they won’t work.
  • the URI must be accessible to nodes on remote computers or devices, so this address needs to be set based on which network we expect these remote computers to be. That’s why ROS wiki warns against using localhost, because this is not normally accessible from a remote PC unless it’s specifically configured to be.

And that’s it! Now you are a master of ROS_MASTER_URI 🙂 .

Extra: Video

Prefer to see the ‘sights and sounds’ version of this post? We made this video just for you!

[youtube https://www.youtube.com/watch?v=xexYf5yuqes&w=560&h=315]

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. Thank you!

Topics:
Masterclass 2023 batch2 blog banner

Check Out These Related Posts

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