Ask Your Question
17

Is there a C++ API for a dynamic reconfigure client?

asked 2011-12-08 10:19:10 -0500

Thomas D gravatar image

updated 2014-01-28 17:10:57 -0500

ngrennan gravatar image

Is there a C++ API that I can use from within a C++ node that will create a dynamic reconfigure client? I would like my node to be able to modify some of the base_local_planner parameters, such as the min/max velocities, during run time.

I have looked at the dynamic_reconfigure wiki and the client API pages and I only see a way to use a Python client node to update variables on a dynamic reconfigure server.

edit retag flag offensive close merge delete

Comments

I'm looking for this, too and till today did not find anything. :(
Achim gravatar imageAchim ( 2012-01-05 22:51:18 -0500 )edit

Just came across the same problem. The use a dynamic_reconfigure server in TrajectoryPlannerROS, but according to the wiki there still is no C++ api. Or has anyone found out if there is a (hidden) C++ api that can make a client?

Kai Bublitz gravatar imageKai Bublitz ( 2012-03-08 02:39:58 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
27

answered 2013-05-31 02:02:40 -0500

fivef gravatar image

I had quite a hard time implementing this. So here my example:

/joint_commander is the node the dynamic_reconfigure server runs in.

Includes:

#include <dynamic_reconfigure/DoubleParameter.h>
#include <dynamic_reconfigure/Reconfigure.h>
#include <dynamic_reconfigure/Config.h>

In your function:

dynamic_reconfigure::ReconfigureRequest srv_req;
dynamic_reconfigure::ReconfigureResponse srv_resp;
dynamic_reconfigure::DoubleParameter double_param;
dynamic_reconfigure::Config conf;

double_param.name = "kurtana_pitch_joint";
double_param.value = pitch;
conf.doubles.push_back(double_param);

double_param.name = "kurtana_roll_joint";
double_param.value = yaw;
conf.doubles.push_back(double_param);

srv_req.config = conf;

ros::service::call("/joint_commander/set_parameters", srv_req, srv_resp);
edit flag offensive delete link more

Comments

This worked flawlessly, thanks so much!

Dave Coleman gravatar imageDave Coleman ( 2013-09-19 15:35:59 -0500 )edit

I tried to implement this in the same node that was providing the dynamic reconfigure service, and it blocks forever in the default setup which only has one thread- the solution is to use an AsyncSpinner with at least two threads, and wrap critical stuff in mutex locks.

lucasw gravatar imagelucasw ( 2015-07-08 10:41:26 -0500 )edit

Do you have some examples of that?

postal gravatar imagepostal ( 2016-03-15 10:17:18 -0500 )edit
1

No public examples, but I implemented a server along the lines of http://wiki.ros.org/dynamic_reconfigu... and then adapted the above code, and then instead of ros::spin() I did ros::AsyncSpinner spinner(1); spinner.start();

lucasw gravatar imagelucasw ( 2016-03-15 19:58:08 -0500 )edit

Though I'm not sure why I didn't do spinner(2) for two threads, and why there wasn't a waitForShutdown() as in http://wiki.ros.org/roscpp/Overview/C... - I'm looking at code that is ifdeffed out, unfortunately.

lucasw gravatar imagelucasw ( 2016-03-15 19:59:25 -0500 )edit

In my case, when I adjust that code, my dynamic reconfigure was died.... everyone is working well?

Sam lee gravatar imageSam lee ( 2017-12-06 21:03:27 -0500 )edit

So it can't be called from callback?

achmad_fathoni gravatar imageachmad_fathoni ( 2018-09-22 18:21:06 -0500 )edit

This worked for me on JADE with 14.04 LTS to configure RASPICAM node. Used from within a private class function (called from with a callback)

If fivef is still around, Thank you!

billy gravatar imagebilly ( 2019-03-09 21:50:47 -0500 )edit
0

answered 2019-05-09 15:07:07 -0500

Looks like someone added a C++ API in June 2016. I'm not sure how to use it or how it compares in performance to the python Client, but you can see the commit details here https://github.com/ros/dynamic_reconf... .

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

8 followers

Stats

Asked: 2011-12-08 10:19:10 -0500

Seen: 7,584 times

Last updated: Jan 28 '14