Publish
Send messages to ROS 2 network
Libraries:
ROS Toolbox /
ROS 2
Description
The Publish block takes in as its input a Simulink® non-virtual bus that corresponds to the specified ROS 2 message type and publishes it to the ROS 2 network. It uses the node of the Simulink model to create a ROS 2 publisher for a specific topic. This node is created when the model runs and is deleted when the model terminates. If the model does not have a node, the block creates one.
On each sample hit, the block converts the Msg input from a Simulink bus signal to a ROS 2 message and publishes it. The block does not distinguish whether the input is a new message but instead publishes it on every sample hit. For simulation, this input is a MATLAB® ROS 2 message. In code generation, it is a C++ ROS 2 message.
Quality of Service (QoS) events related to different QoS policies trigger default warnings for Publish block. For more information on the different QoS events and the triggered warnings respectively, see QoS Events section in Manage Quality of Service Policies in ROS 2 example.
Ports
Input
Parameters
Extended Capabilities
Version History
Introduced in R2019b