Publish messages on a topic
Use the ros2publisher object to publish messages on a topic. When messages are published on that topic, ROS 2 nodes that subscribe to that topic receive those messages directly.
creates a publisher, pub
= ros2publisher(node
,topic
)pub
, for a topic with name
topic
that already exists on the ROS 2 network.
node
is the ros2node
object handle to which the
publisher should attach. The publisher gets the topic message type from the network topic
list.
Note
The topic must be on the network topic list.
specifies additional options using one or more name-value pair arguments. Specify
name-value pair arguments after all other input arguments.pub
= ros2publisher(___,Name,Value
)
[
returns a message, pub
,msg
]
= rospublisher(___)msg
, that you can send with the publisher,
pub
. The message is initialized with default values. You can also
get the ROS message using the ros2message
function.
ros2message | Create ROS 2 message structures |
send | Publish ROS 2 message to topic |