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

Modifying parameter values "rqt_reconfigure" using a python script

asked 2020-08-10 07:24:07 -0600

mateusguilherme gravatar image

updated 2020-08-10 07:24:37 -0600

hi

How can I change a parameter that is available on the "rqt_reconfigure" interface using a python script? For example, I would like to change the "max_vel_x" parameter from a certain place automatically, using a script.

thanks

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2020-09-17 06:27:48 -0600

Ahmed Osman gravatar image

complete example

#!/usr/bin/env python

import dynamic_reconfigure.client
import rospy

rospy.init_node('rs_config_modifier', anonymous=True)

exposure_roi_client = dynamic_reconfigure.client.Client("camera/stereo_module/auto_exposure_roi",timeout=60)
hole_filling_client = dynamic_reconfigure.client.Client("camera/hole_filling",timeout=60)

exposure_roi_params = { 'left' : 169, 'right' : 678, 'top' : 95, 'bottom' : 384 }
exposure_roi_client.update_configuration(exposure_roi_params)

hole_filling_params = { 'holes_fill' : 2}
hole_filling_client.update_configuration(hole_filling_params)
edit flag offensive delete link more
1

answered 2020-08-10 08:23:26 -0600

Delb gravatar image

You should check this wiki that explains how to use the dynamic reconfigure python API. To detail what you need here :

Import the client :

import dynamic_reconfigure.client

Create a client instance of the node to reconfigure :

node_name=<node_to_reconfigure>
client = dynamic_reconfigure.client.Client(node_name)

Make sure to give the full name of the node if you have prefixes, the client will look for the service node_name/set_parameters, you can check with rosservice list the propper node name instead of using rosnode list (if the dynamic reconfigure server has been created under another nodehandle for example).

And calling update_configuration with a dictionary of changes to make :

#params = { 'my_string_parameter' : 'value', 'my_int_parameter' : 5 }
params = { 'max_vel_x' : 5.0 }
config = client.update_configuration(params)
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2020-08-10 07:24:07 -0600

Seen: 615 times

Last updated: Sep 17 '20