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

Dynamic reconfigure and parameter namespaces in octomap_server

asked 2015-06-02 06:37:43 -0600

Hi, I'm improving the reconfigure server of the octomap_server package. However, I am facing the problem that some of the parameters have a name space: sensor_model/max_range for instance. In the reconfigure callback, this is not a huge problem as I added the following line to the .cfg file:

gen.add("max_range", double_t, 0, "Sensor maximum range", -1.0, -1.0, 100)

And in the reconfigure callback:

m_maxRange = config.max_range;

Therefore I can work with the reconfigure server as usual. However, if I load any parameter with rosparam or through a launch file, the loaded value will not match with the dynamic reconfigure value. Is there any way to properly _link_ the max_range parameter of the .cfg to the corresponding name in the parameter server, sensor_model/max_range?

Thank you.

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
1

answered 2015-06-17 13:14:27 -0600

lucasw gravatar image

updated 2015-07-16 12:57:47 -0600

The answer to http://answers.ros.org/question/57498... has a line (and the context is useful also, but this is the key thing I assume causes the values as seen in rqt_dynamic_configure or elsewhere to be changed):

    dynamic_reconfigure_server.updateConfig(config);

Update

This is something I just tried in python that didn't require the node hosting the server to call its own set_parameters service (and thus requiring multiple threads and mutex protection)

    x = rospy.get_param("z", 0.0)
    y = rospy.get_param("z", 0.0)
    self.srv.update_configuration({\
            "x":x,
            "y":y,
            })

This is sort of shown in one tutorial, but the client is using it rather than going direct on the server. I'd like to figure out how to do this in C++ now.

edit flag offensive delete link more

Comments

Thank you for the info. I will take a look at this. However, it is a bit disappointing that dynamic reconfigure cannot take into account such parameter names.

Javier V. Gómez gravatar image Javier V. Gómez  ( 2015-06-19 06:02:07 -0600 )edit

So it is working now, but interestingly I did not add the suggested line. It just worked, now the initial values match the configuration. Thank you anyway!

Javier V. Gómez gravatar image Javier V. Gómez  ( 2015-06-19 08:39:28 -0600 )edit

Recently I wanted to have params override the dynamic reconfigure .cfg defaults, I had to make my node multi-threaded with AsyncSpinner (can't call a service provided by the same single thread node, the call methods block instead of calling back). If you have a better way I'd like to know about it.

lucasw gravatar image lucasw  ( 2015-07-09 21:10:47 -0600 )edit
1

I just loaded the param file with rosparam and it overrode the .cfg defaults. It wasn't working at the beginning but then it worked, with no important changes I would say.

Javier V. Gómez gravatar image Javier V. Gómez  ( 2015-07-10 02:08:24 -0600 )edit

I tried using regular params in the launch file for my node, but they didn't override the cfg values, so I'm using the above (ugly) method now.

lucasw gravatar image lucasw  ( 2015-07-16 12:39:38 -0600 )edit

I've since gotten updateConfig working and I run that after getting the params in my constructor, it doesn't require multiple threads.

lucasw gravatar image lucasw  ( 2015-07-20 10:39:56 -0600 )edit
0

answered 2015-07-16 13:25:12 -0600

thebyohazard gravatar image

There is a not-very-documented feature called groups for dynamic reconfigure that I use to put dynamic reconfigure parameters in namespaces.

However, when using groups, don't rely on the dynamic reconfigure callback to initialize the default value. I'm having to initialize them by the parameter server in my constructor. The dynamic part works, though.

edit flag offensive delete link more

Comments

Yeah but at the start you have an offset between the dynamic reconfigure GUI parameters and the real parameters, right?

Javier V. Gómez gravatar image Javier V. Gómez  ( 2015-07-17 01:57:30 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2015-06-02 06:37:43 -0600

Seen: 2,739 times

Last updated: Jul 16 '15