ROS Network Access in 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
Blocks
ROS Apply Transform, ROS 2 Apply Transform | Transform input ROS or ROS 2 message to target frame (Since R2023b) |
Blank Message | Create blank message using specified message type |
Call Service | Call service in ROS network |
Current Time | Retrieve current ROS time or system time |
Get Parameter | Get values from ROS parameter server |
Get Transform | Get transformation between source and target frame from ROS network (Since R2023b) |
Header Assignment | Update fields of ROS message header (Since R2021a) |
Publish | Send messages to ROS network |
Read Data | Play back data from log file |
Read Image | Extract image from ROS Image message |
ROS Read Scan, ROS 2 Read Scan | Extract scan data from ROS or ROS 2 laser scan message (Since R2022a) |
Read Point Cloud | Extract point cloud from ROS PointCloud2 message |
Set Parameter | Set values on ROS parameter server |
Subscribe | Receive messages from ROS network |
ROS Write Image, ROS 2 Write Image | Write image data to a ROS or ROS 2 message (Since R2022a) |
ROS Write Point Cloud, ROS 2 Write Point Cloud | Write point cloud data to a ROS or ROS 2 message (Since R2022a) |
Topics
ROS Network
- ROS and ROS 2 Simulink Support and Limitations
ROS Toolbox does not support these ROS features in Simulink: - Get Started with ROS in Simulink
Use Simulink blocks for ROS to send and receive messages from a local ROS network. - Configure ROS Network Addresses
Configure ROS Network Addresses Dialog - Connect to a ROS-enabled Robot from Simulink
Configure Simulink to connect to a separate robot simulator using ROS and then send velocity commands, and receive position information from a simulated robot. - ROS Parameters in Simulink
Details for setting ROS parameters in Simulink. - Connect to ROS Device
Parameters for connecting to a ROS device. - ROS Simulink Interaction
Simulink and ROS Interaction Overview
ROS Messages
- Work with ROS Messages in Simulink
Work with complex ROS messages in Simulink, such as messages with nested sub-messages and variable-length arrays. - Select ROS Topics, Messages, and Parameters
Dialog box descriptions for selection ROS topics and messages. - Log ROS Messages from Simulink to a Rosbag Logfile
Save ROS message data from Simulink to a rosbag file. - Use ROS Logger App to Save ROS Messages from Simulink
Use ROS Logger app to record ROS messages during Simulink simulation. - Manage Array Sizes for ROS Messages in Simulink
Description of dialog box for managing array sizes in Simulink ROS
ROS Applications
- Generate a Standalone ROS Node from Simulink
Generate and build a standalone ROS node from a Simulink model. - Feedback Control of a ROS-Enabled Robot
Use Simulink to control a simulated robot running in a separate ROS-based simulator. - Sign-Following Robot with ROS in Simulink
Use Simulink to control a simulated robot running on a separate ROS-based simulator. - Automated Parking Valet with ROS in Simulink
Distribute an automated parking valet application among various nodes in a ROS network in Simulink. - Generate Code to Manually Deploy a ROS Node from Simulink
This example shows you how to generate C++ code from a Simulink model to deploy as a standalone ROS node. - Emergency Braking of Ego Vehicle in CARLA Simulator Using Simulink and CARLA ROS Bridge
Emergency braking of ego vehicle in CARLA using Simulink.
Model Execution
- Enable External Mode for ROS Toolbox Models
External mode enables Simulink on your host computer to communicate with a deployed model on your robotics hardware during runtime. - Enable ROS Time Model Stepping for Deployed ROS Nodes
You can enable a deployed ROS node to execute based on the time published on the/clock
topic on a ROS network. - Tune Parameters and View Signals on Deployed Robot Models Using External Mode
External mode enables Simulink models on your host computer to communicate with a deployed model on your robot hardware during runtime. - Overrun Detection with Deployed ROS Nodes
You can enable overrun detection for a deployed ROS node.