rosrate
Execute loop at fixed frequency
Description
The rosrate
object uses the rateControl
(Robotics System Toolbox) superclass to inherit most of its properties and methods. The
main difference is that rateControl
uses the ROS node as a source for
time information. Therefore, it can use the ROS simulation or wall clock time (see the
IsSimulationTime
property).
If rosinit
creates a ROS
master in MATLAB®, the global node uses wall clock time.
The performance of the rosrate
object and the ability to maintain
the DesiredRate
value depends on the publishing of the clock
information in ROS.
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
. 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