You can enable a deployed ROS node to execute based on the time published on the
/clock topic on a ROS network. To deploy a ROS node from Simulink®, see Generate a Standalone ROS Node from Simulink®.
When you enable ROS time model stepping, the deployed ROS node executes when the published ROS time is a multiple of the base rate of the model. To enable model stepping based on ROS time:
Under the Modeling tab, click Model Settings for your model.
Under Hardware Implementation, set
Hardware board to
Robot Operating System
Under Target Hardware resources > ROS time, select Enable ROS time model stepping.
To specify a topic to publish a notification when the model executes, check the
Enable notification after step check box, and use the
Notification topic (default is
Subscribe to the topic to get a message every time ROS time is published. The
ROS node publishes a
std_msgs/String message type with a string
'-' and the model name
+rostime_test, for example). A
'+' indicates the
model was stepped. A
'-' indicates the published ROS time was not a
multiple of the base rate of the model.
After enabling model stepping and setting a notification topic, you can re-build and deploy your model. When starting the ROS node, the model waits for the ROS time to be published.
You can also enable overrun detection if the model execution is still processing when the next step is triggered by the ROS time. For more information, see Overrun Detection with Deployed ROS Nodes.