Ask Your Question
0

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

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 imageytosclee ( 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 imageytosclee ( 2018-08-16 11:08:46 -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 imageytosclee ( 2018-08-16 19:06:40 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

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

Seen: 345 times

Last updated: Aug 16 '18