Main Content

ROS in Simulink

Access ROS networks and messages using Simulink®

ROS Toolboxenables you to connect to ROS and ROS 2 in Simulink and send messages over the network. See开始与ROS在仿真软件®金宝app.

You can also generate and deploy code to a target system. For an advanced example on creating a standalone ROS node, seeGenerate a Standalone ROS 2 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 usingrosdevice.

Functions

expand all

rosdevice Connect to remote ROS device
runNode Start ROS or ROS 2 node
stopNode Stop ROS or ROS 2 node
runCore Start ROS core
stopCore Stop ROS core
isNodeRunning Determine if ROS or ROS 2 node is running
isCoreRunning Determine if ROS core is running
ros2device Connect to remote ROS 2 device
runNode Start ROS or ROS 2 node
stopNode Stop ROS or ROS 2 node
isNodeRunning Determine if ROS or ROS 2 node is running

Blocks

expand all

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
Header Assignment Update fields of ROS message header
Publish Send messages to ROS network
Read Data Play back data from log file
Read Image Extract image from ROS Image message
Read Point Cloud Extract point cloud from ROS PointCloud2 message
Set Parameter Set values on ROS parameter server
Subscribe Receive messages from ROS network
Blank Message Create blank ROS 2 message using specified message type
Call Service Call service in ROS 2 network
Publish Send messages to ROS 2 network
Read Data Play back data from ROS 2 log file
Read Image Extract image from ROS 2Imagemessage
Read Point Cloud Extract point cloud from ROS 2PointCloud2message
Subscribe Receive messages from ROS 2 network

Topics

ROS Network

ROS Simulink Support and Limitations

The ROS Toolbox does not support the following ROS features in Simulink:

开始与ROS在仿真软件®金宝app

This example shows how to 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®

You can use Simulink to connect to a ROS-enabled physical robot or to a ROS-enabled robot simulator such asGazebo.

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®

This example illustrates how to 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.

Manage Array Sizes for ROS Messages in Simulink

Description of dialog box for managing array sizes in Simulink ROS

ROS 2 Network

Get Started with ROS 2 in Simulink®

This example shows how to use Simulink blocks for ROS 2 to send and receive messages from a local ROS 2 network.

Publish and Subscribe to ROS 2 Messages in Simulink

This model shows how to publish and subscribe to a ROS 2 topic using Simulink®.

Connect to a ROS-Enabled Robot from Simulink® over ROS 2

这个例子向您展示了如何配置一个仿真软件金宝appmodel to send and receive information from a separate ROS-based simulator such as Gazebo® over ROS 2.

ROS Applications

Generate a Standalone ROS Node from Simulink®

This example shows you how to 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

This example shows how to 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.

ROS 2 Applications

Generate a Standalone ROS 2 Node from Simulink®

This example shows you how to generate and build a standalone ROS 2 node from a Simulink® model.

Feedback Control of a ROS-Enabled Robot Over ROS 2

This example shows you how to use Simulink® to control a simulated robot running in a Gazebo® robot simulator over ROS 2 network.

Sign Following Robot with ROS 2 in Simulink

Use Simulink® to control a simulated robot running on a separate ROS-based simulator over ROS 2 network.

Automated Parking Valet with ROS 2 in Simulink

This example shows how to distribute the Automated Parking Valet application among various nodes in a ROS 2 network in Simulink® and deploy them as standalone ROS 2 nodes.

Generate Code to Manually Deploy a ROS 2 Node from Simulink®

This example shows you how to generate C++ code from a Simulink® model to deploy as a standalone ROS 2 node.

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/clocktopic on a ROS network.

调优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.