0
$\begingroup$

Rosanswers logo

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


Originally posted by mateusguilherme on ROS Answers with karma: 125 on 2020-08-10

Post score: 0

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

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)

Originally posted by Ahmed Osman with karma: 56 on 2020-09-17

This answer was ACCEPTED on the original site

Post score: 1

$\endgroup$
0
$\begingroup$

Rosanswers logo

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)

Originally posted by Delb with karma: 3907 on 2020-08-10

This answer was NOT ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.