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

How to publish data changed in Dynamic Reconfigure

asked 2018-08-15 10:27:05 -0500

ytosclee gravatar image

updated 2018-08-16 11:04:39 -0500

Does anyone have an example code on how to read the data from "/node/parameter_updates"? Thanks a lot!

edit retag flag offensive close merge delete

Comments

1

What I really want to do is to publish the value change in dynamic configure into a topic. I want to use dynamic reconfigure to build a PID tuner. I look at the topic "/node/parameter_updates" but I have no idea how to get the value using the name.

ytosclee gravatar image ytosclee  ( 2018-08-16 11:06:18 -0500 )edit

I googled and saw that the values are mirrored in the parameter server and we can use getParamCache to check if any value is changed. Anyone has an example code that I can refer to? I just want to find an easy way to publish the value change in dynamic reconfigure into a topic. Thanks a lot!

ytosclee gravatar image ytosclee  ( 2018-08-16 11:08:46 -0500 )edit

Hi ytosclee, I am trying to accomplish the same task. Have you found a way to change the values on the parameter_updates message to update the PID gains?

funky_watermelon gravatar image funky_watermelon  ( 2020-05-19 08:16:31 -0500 )edit

Hi Funky_Watermelon, yes, the dynamic configure will create ROS parameters. So you can get/update the value using the ROS parameters.

ytosclee gravatar image ytosclee  ( 2020-05-19 22:12:28 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-08-16 12:46:12 -0500

lucasw gravatar image

The easiest way is to use an existing dynamic reconfigure client which does the work of converting to or from messages on that topic into the cfg type which is delivered to a callbac, or published out via update_configuration() : http://wiki.ros.org/dynamic_reconfigu... or http://wiki.ros.org/dynamic_reconfigu...

Or you can do the same on the server side.

But if you want to use the raw message (implementing your own custom client or server) you can:

$ rostopic info /example_server_node/parameter_updates
Type: dynamic_reconfigure/Config
...

$ rosmsg show dynamic_reconfigure/Config
dynamic_reconfigure/BoolParameter[] bools
  string name
  bool value
dynamic_reconfigure/IntParameter[] ints
  string name
  int32 value
dynamic_reconfigure/StrParameter[] strs
  string name
  string value
dynamic_reconfigure/DoubleParameter[] doubles
  string name
  float64 value
dynamic_reconfigure/GroupState[] groups
  string name
  bool state
  int32 id
  int32 parent

Using the above information you can populate a Config message for publishing or decipher it in a subscriber callback. Use push_back for C++ or append in python to add IntParameters or any of the other types. You just need to use the same names in the right type slots as in the cfg file. (I believe if you only partially populate it still works, and extra names that don't match any in the cfg are ignored silently, but I haven't tried that)

I'm not sure how the groups work but if you rostopic echo an example with a group in it maybe it is self explanatory.

edit flag offensive delete link more

Comments

Hi Lucasw: Thanks a lot for your help! Best Regards, Ytosclee

ytosclee gravatar image ytosclee  ( 2018-08-16 19:06:40 -0500 )edit

Question Tools

3 followers

Stats

Asked: 2018-08-15 10:27:05 -0500

Seen: 1,532 times

Last updated: Aug 16 '18