controller_manager update rate
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.
To avoid a possible xy-problem: do you really need the update rate, or the delta t?
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.
I don't know of any API for this. Controllers are passed
t
anddt
in theirupdate(..)
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. Thejoint_state_controller
is one such .... example (see here fi). In that particular case it's a private member variable, so not sure how useful that is for you.
Perhaps a board member with more in-depth knowledge of
ros_control
answers your question.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 specificx
, but I would still need to know the actual controller frequency to make sure thatx
is achievable.... 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.the
controller_manager
does not callupdate(..)
. That is the responsibility of the entity running the control loop, which is typically done in the 'hw interface node'.