ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

answered Aug 5 '14

Airuno2L gravatar image

This link should have all the information you need.

There are many ways to get:

global_name = rospy.get_param("/global_name")
relative_name = rospy.get_param("relative_name")
private_param = rospy.get_param('~private_name')    
default_param = rospy.get_param('default_param', 'default_value')

# fetch a group (dictionary) of parameters
gains = rospy.get_param('gains')
p, i, d = gains['P'], gains['I'], gains['D']

And set:

rospy.set_param('a_string', 'baz')
rospy.set_param('~private_int', 2)
rospy.set_param('list_of_floats', [1., 2., 3., 4.])
rospy.set_param('bool_True', True)
rospy.set_param('gains', {'p': 1, 'i': 2, 'd': 3})

rospy.get_param('gains/P') #should return 1

You can do a lot of other things like delete params, check and see if a param exists, list all params, etc. All of it is covered in that link.

click to hide/show revision 2
No.2 Revision

This link should have all the information you need.

There are many ways to get:

global_name = rospy.get_param("/global_name")
relative_name = rospy.get_param("relative_name")
private_param = rospy.get_param('~private_name')    
default_param = rospy.get_param('default_param', 'default_value')

# fetch a group (dictionary) of parameters
gains = rospy.get_param('gains')
p, i, d = gains['P'], gains['I'], gains['D']

And set:

rospy.set_param('a_string', 'baz')
rospy.set_param('~private_int', 2)
rospy.set_param('list_of_floats', [1., 2., 3., 4.])
rospy.set_param('bool_True', True)
rospy.set_param('gains', {'p': 1, 'i': 2, 'd': 3})

rospy.get_param('gains/P') #should return 1

You can do a lot of other things like delete params, check and see if a param exists, list all params, etc. All of it is covered in that link.

This might be of interest to. It looks like someone already had something like this but used the rx stuff (I just skimmed it, you might want to look closer).

Lastly, if you do build a plugin, please let people know about it here to prevent duplicate efforts. I also notice on that page that the description of the Node_Manager plugin says something about managing params, you might want to look at that to.