Publishing a ROS message in Simulink

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:

Figure 15: Parameter configuration ...

Get Mastering ROS for Robotics Programming - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.