What is ROS Parameter Server?

What-is-ROS-Parameter-Server-

Written by Bayode Aderinola

25/06/2018

Hello ROS Developers! In this post, we will see what the ROS parameter server is in less than 5 minutes! We’ll see what it entails and some of the commands we can use to work with it within the 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. That’s the option I’m using for this post.

  1. You have ROS installed locally, such that kinetic <= version < crystal. Good to go; just be ready to spin up a terminal.
  2. You don’t have ROS installed but you have docker: 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 rosparam_demo. 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 the ROS Parameter Server

Open a terminal and run the following command:

user:~$ rosparam list
ERROR: Unable to communicate with master!

I got my fingers burned while trying that command…ouch! The parameter server is part of the ROS master, so we need to get it started first. If you didn’t get your fingers burned, then you “cheated” – you had the ROS master running previously 🙂 .

Now let’s do the right thing by starting the master first. In another terminal, run

user:~$ roscore
...

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


SUMMARY
========
PARAMETERS
 * /rosdistro: kinetic
 * /rosversion: 1.12.14

NODES

auto-starting new master
process[master]: started with pid [22611]

...

We can already see two parameters listed under the heading “PARAMETERS”: /rosdistro and /rosversion, from the output of the command above. But back up there and let’s rerun the “finger-burning” command:

user:~$ rosparam list
ERROR: Unable to communicate with master!
user:~$ rosparam list
/rosdistro
/roslaunch/uris/host_instance__45696
/rosversion
/run_id

Great, now I got away with my fingers intact, and here we have a list of all current ROS parameters, including the ones mentioned earlier in the roscore command output. Next, let’s explore another sub-command of rosparam: get.

user:~$ rosparam get /roslaunch/uris/host_instance__45696
http://instance:45696/
user:~$ rosparam get /roslaunch/uris/
{host_instance__45696: 'http://instance:45696/'}
user:~$ rosparam get /roslaunch
uris: {host_instance__45696: 'http://instance:45696/'}

I decided to get one of the params from the list command that demonstrates that ROS parameters can be stored and retrieved in hierarchies, to store related parameters and to prevent parameter names from colliding.

Finally, let’s explore one more command: set.

user:~$ rosparam set /our_own_param "learning ROS params"
user:~$ rosparam list
/our_own_param
/rosdistro
/roslaunch/uris/host_instance__45696
/rosversion
/run_id
user:~$ rosparam get /our_own_param
learning ROS params

You get the gist! Finally, here’s a list of commands available for working with ROS parameters; have fun exploring them!

user:~$ rosparam -h
rosparam is a command-line tool for getting, setting, and del
eting parameters from the ROS Parameter Server.

Commands:
        rosparam set    set parameter
        rosparam get    get parameter
        rosparam load   load parameters from file
        rosparam dump   dump parameters to file
        rosparam delete delete parameter
        rosparam list   list parameter names

And that’s it! Now’s let wrap up by doing some “small talk” about the topic.

Step 3: Master the concept – what is ROS Parameter Server?

I believe that by now you know what the ROS parameter server is in practiceIn theory, according to ROS Wiki, “A parameter server is a shared, multi-variate dictionary that is accessible via network APIs. Nodes use this server to store and retrieve parameters at runtime.”

You can use the parameter server to store data that you want to access ‘globally’ from your ROS code. Since it exists on the ROS master, it’s available to all nodes and all machines connected to the master.

You can read more about the parameter server from the ROS Wiki: http://wiki.ros.org/Parameter%20Server.

endsmalltalk.

Extra: Video

Not a “postworm” and prefer to see the ‘sights and sounds’ version of this post? We made this video just for you!

Feedback

If you want to learn more about ROS parameters, please remember to check our ROS Basics In 5 Days (Python)  course!

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!

Masterclass 2023 batch2 blog banner

Check Out These Related Posts

2 Comments

  1. sukhman

    I never see such a difficult topic explained in just 5 min. Hats off.

    Reply
  2. Sukhman

    I never see any difficult topic explained in just 5 min. Hats off.

    Reply

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