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

Max frequency to look up parameters

asked 2014-09-08 22:21:49 -0500

Wes G gravatar image

I'm in the early stages of building the brains of my robot and have a question about best practices. The nodes that I'm working on have certain values that will change frequently during tuning, so they're stored in the parameter server.

In the case of my joystick teleop node, every Joy message uses some scale to determine outputs but if you called getparam for every message, I'm assuming you'd overload the server, given they'll be received multiple times per second. It's the same story for other nodes so I came up with multiple solutions that I'm hoping others have already figured out, and can provide feedback (using the teleop node as an example)

  1. Call getParam to look up the scale values with each message (not recommended, could overload server)
  2. Call getCached in each message (tutorial seems to suggest this isn't a good idea either, as it has more overhead)
  3. Load parameters when the node starts (good, but requires resetting the node to update values)
  4. Load parameters at start, but also include an empty service that updates the values while the node is running (useful for complex nodes, like PID controllers)

At the moment my more advanced nodes are using #4. Is there another solution I've missed, or perhaps a generally accepted retrieval rate for given hardware?

edit retag flag offensive close merge delete

Comments

How are those parameters changed? If you change them by hand have a look at dynamic reconfigure. This will call a callback function in your node each time a parameter is changed in the dynamic reconfigure rqt plugin.

BennyRe gravatar image BennyRe  ( 2014-09-08 23:52:13 -0500 )edit

Which tutorial suggest that getCachedParam has more overhead? In what way more overhead?

tfoote gravatar image tfoote  ( 2014-09-09 00:12:28 -0500 )edit
1

On the page about the parameter server, it says "Cached parameters are a significant speed increase (after the first call), but should be used sparingly to avoid overloading the master." I'm not sure why it overloads, though

Wes G gravatar image Wes G  ( 2014-09-09 08:03:24 -0500 )edit
1

This is a warning about overusing parameters. You don't want to use parameters for all local variables and store them all on the parameter server. Any individual cached parameter is not going to overload the parameter server, but if everything goes through the paremeter server it will not scale.

tfoote gravatar image tfoote  ( 2014-09-09 16:43:28 -0500 )edit

Did some testing. I called rospy.get_param() at 100Hz. It added around 9% of CPU usage which is A LOT. Knowing this I can confirm that using parameter server for in-loop updates is very inefficient and should never be used. Parameter server is only for initialization. For frequent updates I would use latched topics instead.

Combinacijus gravatar image Combinacijus  ( 2020-01-31 06:50:41 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-09-09 16:44:26 -0500

tfoote gravatar image

Probably the best solution for your problem is to use dynamic reconfigure. Tutotrials here: http://wiki.ros.org/dynamic_reconfigu...

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2014-09-08 22:21:49 -0500

Seen: 799 times

Last updated: Sep 09 '14