rosrate
Execute loop at fixed frequency
Description
The rosrate object allows you to execute a loop at a fixed
frequency. The rosrate object uses the global ROS node as a source
for time information. Therefore, it can use the ROS simulation or wall clock time (see
the IsSimulationTime property).
The performance of the rosrate object, and the ability to maintain
the desiredRate value depend on the publishing of the clock
information in ROS network. Because the rosrate object relies on the
pause function, disabling pause will result in
inaccurate execution.
If rosinit creates a ROS
master in MATLAB®, the global node uses wall clock time.
Tip
The scheduling resolution of your operating system and the level of other system activity can affect rate execution accuracy. As a result, accurate rate timing is limited to 100 Hz for execution of MATLAB code. To improve performance and execution speeds, use code generation.
Creation
Description
creates a rate = rosrate(desiredRate)Rate object, which enables you to execute a
loop at a fixed frequency, DesiredRate. This syntax
sets the DesiredRate and
DesiredPeriod properties of the
Rate object. The time source is linked to the time
source of the global ROS node, which requires you to connect MATLAB to a ROS network using rosinit.
creates a rate = ros.Rate(node,desiredRate)Rate object that operates loops at a fixed rate
based on the time source linked to the specified ROS node,
node.
Properties
Object Functions
waitfor | Pause code execution to achieve desired execution rate |
statistics | Statistics of past execution periods |
reset | Reset Rate object |
Examples
Extended Capabilities
Version History
Introduced in R2019b
