MATLAB 内の ROS 2
MATLAB® を使用して ROS 2 のネットワークおよびメッセージにアクセスする
ROS 2 では、"メッセージ" を使用して情報を共有します。メッセージは、データを共有するための単純なデータ構造体です。メッセージを受信 (すなわちサブスクライブ) するには、ros2subscriber
を使用します。メッセージを送信 (すなわちパブリッシュ) するには、ros2publisher
を使用します。メッセージ送信の詳細については、ROS 2 のパブリッシャーとサブスクライバーとのデータ交換を参照してください。
ROS 2 のサービスとアクションにより、ユーザーはタスクを実行できます。サービスでは、要求と応答の通信を使用して情報を収集し、ROS 2 ネットワークでコールバック関数をトリガーします。アクションを使用すると、タスクやゴールをトリガーし、これらのタスクの操作中にフィードバックを受信できます。
関数
ブロック
トピック
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 ROS 2 のパブリッシャーとサブスクライバーとのデータ交換. - ROS 2 のパブリッシャーとサブスクライバーとのデータ交換
ROS 2 ノードがデータを交換するための主なメカニズムは、"メッセージ" を送受信することです。 - 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. - Manage Quality of Service Policies in ROS 2 Application with TurtleBot
This example demonstrates best practices in managing Quality of Service (QoS) policies for an application using ROS 2. QoS policies allow for the flexible tuning of communication behavior between publishers and subscribers, and change the way that messages are transported within a ROS 2 network. For more information, see Manage Quality of Service Policies in ROS 2. - 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. Theros1_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, seeros1_bridge
. This example uses a virtual machine which may be downloaded by following the instructions in Gazebo およびシミュレートされた TurtleBot の入門. Theros1_bridge
package is installed on this virtual machine.
ROS 2 サービス
- Call and Provide ROS 2 Services
ROS supports two main communication mechanisms: topics and services. Topics have publishers and subscribers and are used for sending and receiving messages (see ROS 2 のパブリッシャーとサブスクライバーとのデータ交換). Services, on the other hand, implement a tighter coupling by allowing request-response communication. A service client sends a request message to a service server and waits for a response. The server will use the data in the request to construct a response message and sends it back to the client. Each service has a type that determines the structure of the request and response messages.