controller_manager update rate

asked 2018-01-16 06:16:19 -0600

IvanV gravatar image

updated 2018-01-16 08:24:30 -0600

I have a controller that uses 2 velocity and 2 position hardware interfaces, and I need to know at which rate the controller is being updated.

How can I know the rate at which the update function is called in controller_manager?

I don't seem to be able to find this information anywhere... Any hint pointing in the right direction will be appreciated.

Thank you.

EDIT:

Getting the data on execution time is not mandatory. It would be enough to know where does controller_manager get the information for calling update. So far, I've been unable to find it, or even a default rate value, even looking at the code.

edit retag flag offensive close merge delete

Comments

To avoid a possible xy-problem: do you really need the update rate, or the delta t?

gvdhoorn gravatar image gvdhoorn  ( 2018-01-16 06:51:17 -0600 )edit

I need to make some computations on the controller that depend on the relation between the controller execution rate and some other input topic publication rate (which I already know). Basically, the controller needs to do something in x steps, where x = controller frequency/topic frequency.

IvanV gravatar image IvanV  ( 2018-01-16 07:50:09 -0600 )edit

I don't know of any API for this. Controllers are passed t and dt in their update(..) methods, so that could perhaps be used.

I don't know how universal it is, but some controllers store the update_rate parameter internally at initialisation. The joint_state_controller is one such ..

gvdhoorn gravatar image gvdhoorn  ( 2018-01-16 08:07:12 -0600 )edit

.. example (see here fi). In that particular case it's a private member variable, so not sure how useful that is for you.

gvdhoorn gravatar image gvdhoorn  ( 2018-01-16 08:08:38 -0600 )edit

Perhaps a board member with more in-depth knowledge of ros_control answers your question.

gvdhoorn gravatar image gvdhoorn  ( 2018-01-16 08:09:05 -0600 )edit

Thank you. However, in that case update_rate is used to guarantee that the controller makes something at a specific rate, which is not my case. I could do something similar to force a specific x, but I would still need to know the actual controller frequency to make sure that x is achievable.

IvanV gravatar image IvanV  ( 2018-01-16 08:19:30 -0600 )edit

... However, I guess I could use dt to compute the current frequency instead of using it as a parameter. Have to check what implications may have a (probably) dynamic x value in the computations.

IvanV gravatar image IvanV  ( 2018-01-16 08:27:40 -0600 )edit

It would be enough to know where does controller_manager get the information for calling update

the controller_manager does not call update(..). That is the responsibility of the entity running the control loop, which is typically done in the 'hw interface node'.

gvdhoorn gravatar image gvdhoorn  ( 2018-01-16 08:33:47 -0600 )edit