パブリッシャーとサブスクライバー

メッセージ、トピックおよびネットワーク情報を作成し、送受信する

ROS では、"メッセージ" を使用して情報を共有します。メッセージは、データを共有するための単純なデータ構造体です。メッセージを受信 (すなわちサブスクライブ) するには、rossubscriber を使用します。メッセージを送信 (すなわちパブリッシュ) するには、rospublisher を使用します。メッセージ送信の詳細については、Exchange Data with ROS Publishers and Subscribersを参照してください。

関数

すべて展開する

rosmessageCreate ROS messages
rosmsgRetrieve information about ROS messages and message types
rostopicRetrieve information about ROS topics
definitionRetrieve definition of ROS message type
showdetailsDisplay all ROS message contents
rospublisherメッセージをトピック上にパブリッシュ
rossubscriberトピック上のメッセージをサブスクライブ
receiveWait for new ROS message
sendPublish ROS message to topic
rosrateExecute loop at fixed frequency
ros2messageCreate ROS 2 message structures
ros2Retrieve information about ROS 2 network
ros2publisherPublish messages on a topic
sendPublish ROS 2 message to topic
ros2subscriberSubscribe to messages on a topic
receiveWait for new ROS message
ros2messageCreate ROS 2 message structures

ブロック

すべて展開する

Blank MessageCreate blank message using specified message type
Blank MessageCreate blank ROS 2 message using specified message type
Current TimeRetrieve current ROS time or system time
PublishSend messages to ROS network
SubscribeReceive messages from ROS network
Blank MessageCreate blank ROS 2 message using specified message type
PublishSend messages to ROS 2 network
SubscribeReceive messages from ROS 2 network

トピック

ROS

Work with Basic ROS Messages

Messages are the primary container for exchanging data in ROS. Topics and services use messages to carry data between nodes. (See Exchange Data with ROS Publishers and Subscribers and Call and Provide ROS Services for more information on topics and services)

Built-In Message Support

List of supported ROS message types in MATLAB®.

Exchange Data with ROS Publishers and Subscribers

The primary mechanism for ROS nodes to exchange data is sending and receiving messages. Messages are transmitted on a topic, and each topic has a unique name in the ROS network. If a node wants to share information, it uses a publisher to send data to a topic. A node that wants to receive that information uses a subscriber to that same topic. Besides its unique name, each topic also has a message type, which determines the types of messages that are capable of being transmitted under that topic.

Work with Specialized ROS Messages

Some commonly used ROS messages store data in a format that requires some transformation before it can be used for further processing. MATLAB® can help you by formatting these specialized ROS messages for easy use. In this example, you can explore how message types for laser scans, uncompressed and compressed images, and point clouds are handled.

ROS 2

Work with Basic ROS 2 Messages

ROS messages are the primary container for exchanging data in ROS 2. Publishers and subscribers exchange data using messages on specified topics to carry data between nodes. For more information on sending and receiving messages, see Exchange Data with ROS 2 Publishers and Subscribers.

Exchange Data with ROS 2 Publishers and Subscribers

The primary mechanism for ROS 2 nodes to exchange data is to send and receive messages. Messages are transmitted on a topic and each topic has a unique name in the ROS 2 network. If a node wants to share information, it must use a publisher to send data to a topic. A node that wants to receive that information must use a subscriber for that same topic. Besides its unique name, each topic also has a message type, which determines the type of messages that are allowed to be transmitted in the specific topic.

Manage Quality of Service Policies in ROS 2

Quality of Service (QoS) policy options allow for changing the behavior of communication within a ROS 2 network. QoS policies are modified for specific communication objects, such as publishers and subscribers, and change the way that messages are handled in the object and transported between them. For any messages to pass between two communication objects, their QoS policies must be compatible.

Using ROS Bridge to Establish Communication between ROS and ROS 2

ROS 2 is newer version of ROS with different architecture. Both the networks are separate and there is no direct communication between the nodes in ROS and ROS 2. The ros1_bridge package provides a network bridge which enables the exchange of messages between ROS and ROS 2. The bridge manages all the conversion required and sends messages across both the networks. For more information, see ros1_bridge. This example uses a virtual machine available for download at Virtual Machine with ROS 2 Melodic and Gazebo. The ros1_bridge package is installed on this virtual machine.