Main Content

ROS Network Access in Simulink

Access ROS 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 in Simulink.

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

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

Note

ROS 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).

ROS 2 blocks are not supported for software-in-the-loop (SIL) and processor-in-the-loop (PIL) simulations.

Functions

expand all

rosdeviceConnect to remote ROS device (Since R2019b)
runNodeStart ROS or ROS 2 node (Since R2019b)
stopNodeStop ROS or ROS 2 node (Since R2019b)
runCoreStart ROS core (Since R2019b)
stopCoreStop ROS core (Since R2019b)
isNodeRunningDetermine if ROS or ROS 2 node is running (Since R2019b)
isCoreRunningDetermine if ROS core is running (Since R2019b)

Blocks

ROS Apply Transform, ROS 2 Apply TransformTransform input ROS or ROS 2 message to target frame (Since R2023b)
Blank MessageCreate blank message using specified message type (Since R2019b)
Call ServiceCall service in ROS network (Since R2019b)
Current TimeRetrieve current ROS time or system time (Since R2019b)
Get ParameterGet values from ROS parameter server (Since R2019b)
Get TransformGet transformation between source and target frame from ROS network (Since R2023b)
Header AssignmentUpdate fields of ROS message header (Since R2021a)
PublishSend messages to ROS network (Since R2019b)
Read DataPlay back data from log file (Since R2019b)
Read ImageExtract image from ROS Image message (Since R2019b)
ROS Read Scan, ROS 2 Read ScanExtract scan data from ROS or ROS 2 laser scan message (Since R2022a)
Read Point CloudExtract point cloud from ROS PointCloud2 message (Since R2019b)
Set ParameterSet values on ROS parameter server (Since R2019b)
SubscribeReceive messages from ROS network (Since R2019b)
ROS Write Image, ROS 2 Write ImageWrite image data to a ROS or ROS 2 message (Since R2022a)
ROS Write Point Cloud, ROS 2 Write Point CloudWrite point cloud data to a ROS or ROS 2 message (Since R2022a)

Topics

ROS Network

ROS Messages

ROS Applications

Model Execution