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
runNodeStart ROS or ROS 2 node
stopNodeStop ROS or ROS 2 node
runCoreStart ROS core
stopCoreStop ROS core
isNodeRunningDetermine if ROS or ROS 2 node is running
isCoreRunningDetermine if ROS core is running

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
Call ServiceCall service in ROS network
Current TimeRetrieve current ROS time or system time
Get ParameterGet values from ROS parameter server
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
Read DataPlay back data from log file
Read ImageExtract image from ROS Image message
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
Set ParameterSet values on ROS parameter server
SubscribeReceive messages from ROS network
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