To publish a ROS message in Simulink, we mainly need two blocks:
- Publish: This block sends a message on the ROS network. Using block parameters, we can specify the topic name and the message type.
- Blank message: This block creates a blank message with the specified message type.
Let's see how to connect these blocks to publish a geometry_msgs/Twist message on a new topic, called /position. Get started by importing the blank message block from the library browser and configuring the type of message by double-clicking on it. From the block parameters pane, we can press the Select button to select the ROS message type from a list, as shown in the following screenshot: