Skip to content
  • Home
  • About the Blog
  • About the Author
  • Sitemap

Abdur Rosyid's Blog

Just a few notes on mechanical engineering and robotics

ROS Parameters

July 7, 2021 by Abdur Rosyid

ROS parameters are parameters in a node which can be modified from their default values. By this definition, the ROS parameters are very useful to be used when we want to be able to modify them quickly, in real-time. ROS parameters can be, for example, USB port numbers, camera calibration parameters, or minimum and maximum motor speeds. The parameters can be of integers, floats, boolean, string, dictionaries, list, and so on.

In C++, a parameter in a node is set and read by using setParam and getParam functions, respectively. These functions can be used with a node handler as the following:

ros::NodeHandle nh;
nh.setParam("parameter_name", parameter_value); // Reset the parameter value
nh.getParam("parameter_name", variable); // Read the parameter value and pass it to variable     

The parameter_value can be directly a value or a variable representing a value. Notice that the data types of the variables “parameter_value” and “variable” above should be declared earlier as any variable needs declaration in C++.

The setParam and getParam can also be used as the following:

ros::param::set("parameter_name", parameter_value);
ros::param::get("parameter_name", variable);

The official documentation can be found here: http://wiki.ros.org/roscpp/Overview/Parameter%20Server

In Python, setting and reading the parameters can be done as follows:

rospy.set_param('parameter_name', parameter_value)
rospy.get_param('parameter_name')
variable = rospy.get_param('parameter_name')

The official documentation can be found here:

  • http://wiki.ros.org/rospy/Overview/Parameter%20Server
  • http://wiki.ros.org/rospy_tutorials/Tutorials/Parameters

CLI Commands for ROS Parameters

The following are the CLI commands regarding ROS parameters:

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

Post navigation

Previous Post:

Creating ROS1 Action

Next Post:

Creating Custom Messages

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Categories

  • STEM 101
  • Robotics
  • Kinematics
  • Dynamics
  • Control
  • Robot Operating System (ROS)
  • Robot Operating System (ROS2)
  • Software Development
  • Mechanics of Materials
  • Finite Element Analysis
  • Fluid Mechanics
  • Thermodynamics

Recent Posts

  • Pull Request on Github
  • Basics of Git and Github
  • Conda vs Docker
  • A Conda Cheat Sheet
  • Installing NVIDIA GPU Driver on Ubuntu

Archives

  • June 2025
  • July 2021
  • June 2021
  • March 2021
  • September 2020
  • April 2020
  • January 2015
  • April 2014
  • March 2014
  • March 2012
  • February 2012
  • June 2011
  • March 2008
© 2026 Abdur Rosyid's Blog | WordPress Theme by Superbthemes