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:
On the Apps tab, under Control Systems, click Robot Operating System (ROS).
In the Robot Operating System (ROS) dialog box that opens up,
Robot Operating System (ROS) from the
ROS Network drop-down. This opens up the
ROS tab in the toolstrip which shows the specified ROS
Network in the Connect section.
In the Prepare section under ROS tab, click Hardware Settings to open the model configuration parameters dialog box. 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.