Main Content

ROS 2 in Simulink

Access ROS 2 networks and messages using Simulink®

ROS Toolbox enables you to connect to ROS and ROS 2 in Simulink and send messages over the network. See Get Started with ROS 2 in Simulink®.

You can also generate and deploy code to a target system. For an advanced example on creating a standalone ROS 2 node, see Generate a Standalone ROS 2 Node from Simulink.

To run, stop, or check the status of deployed ROS 2 nodes available on a ROS 2 device, use the MATLAB® functions listed. Create a connection to a ROS device using ros2device.

Note

ROS 2 blocks are not supported for usage within subsystem references. This is because ROS Toolbox uses a data dictionary to store model information but subsystem reference does not support portability of data dictionary attached to it. For more information on using subsystem references, see Considerations When Using a Library Dictionary (Simulink).

Functions

expand all

ros2deviceConnect to remote ROS 2 device
runNodeStart ROS or ROS 2 node
stopNodeStop ROS or ROS 2 node
isNodeRunningDetermine if ROS or ROS 2 node is running

Blocks

Blank MessageCreate blank ROS 2 message using specified message type
Call ServiceCall service in ROS 2 network
Current TimeRetrieve current ROS 2 time or system time
Get ParameterGet ROS 2 parameter value
Header AssignmentUpdate fields of ROS 2 message header
PublishSend messages to ROS 2 network
Read DataPlay back data from ROS 2 log file
Read ImageExtract image from ROS 2 Image message
Read ScanExtract scan data from ROS or ROS 2 laser scan message
Read Point CloudExtract point cloud from ROS 2 PointCloud2 message
SubscribeReceive messages from ROS 2 network
Write ImageWrite image data to a ROS or ROS 2 message
Write Point CloudWrite point cloud data to a ROS or ROS 2 message

Topics

ROS 2 Network

ROS 2 Messages

ROS 2 Applications

Model Execution