ros2rate
Description
The ros2rate
object allows you to execute a loop at a fixed
frequency. It uses the ROS 2 node as a source for time information. Therefore, it can use the
ROS 2 simulation time or wall clock time (see the IsSimulationTime
property).
The performance of the ros2rate
object, and the ability to maintain the
DesiredRate
value depend on the publishing of the clock information in
ROS 2 network. Because the ros2rate object relies on the pause
function,
disabling pause
will result in inaccurate execution.
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 when executing MATLAB® code. To improve performance and execution speeds, use code generation.
Creation
Description
creates a rate
= ros2rate(node
,desiredRate
)ros2rate
object, rate
, that enables
you to execute a loop at a fixed frequency, desiredRate
. The object
uses the time source of the specified ROS 2 node object,
node
.
Properties
Object Functions
waitfor | Pause code execution to achieve desired execution rate |
statistics | Statistics of past execution periods |
reset | Reset ros2rate object |
Examples
Extended Capabilities
Version History
Introduced in R2022b