ROS2編程基礎課程--概念
Concepts?概念
Overview of ROS 2 Concepts?ROS 2概念概述
ROS 2 and different DDS/RTPS vendors?ROS 2和不同的DDS / RTPS供應商
About Quality of Service Settings?關于服務質量設置
About ROS 2 Interfaces?關于ROS 2接口
About ROS2 client libraries?關于ROS2客戶端庫
Logging and logger configuration?日志記錄和日志記錄器配置
See also?http://docs.ros2.org/?for ROS 2 high level documentation.
有關ROS 2高級文檔,另請參考http://docs.ros2.org/。
Overview of ROS 2 Concepts
ROS 2概念綜述
Table of Contents?目錄
Quick Overview of Graph Concepts?圖概念的快速概述
Nodes?節點
Client Libraries?客戶端庫
Discovery?消息發現機制
Example: talker-listener?示例:發布器-訂閱器
ROS is a middleware based on an anonymous publish/subscribe mechanism that allows for message passing between different ROS processes.
ROS是一種基于匿名發布/訂閱機制的中間件,允許在不同的ROS進程之間傳遞消息。
At the heart of any ROS 2 system is the ROS graph. The ROS graph refers to the network of nodes in a ROS system and the connections between them by which they communicate.
任何ROS 2系統的核心是ROS圖。ROS圖指的是ROS系統中的節點網絡以及它們之間通信的連接。
ROS2 turtlesim Graph
Quick Overview of Graph Concepts
圖概念的快速概述
Nodes: A node is an entity that uses ROS to communicate with other nodes.
節點:節點是使用ROS與其他節點通信的實體(或實例)。
Messages: ROS data type used when subscribing or publishing to a topic.
消息:訂閱或發布到主題時ROS使用的數據類型。
Topics: Nodes can publish messages to a topic as well as subscribe to a topic to receive messages.
主題:節點可以將消息發布到主題,也可以訂閱主題以接收消息。
Discovery: The automatic process through which nodes determine how to talk to each other.
發現:節點確定如何相互通信的自動過程。
Nodes?節點
A node is a participant in the ROS graph. ROS nodes use a ROS client library to communicate with other nodes. Nodes can publish or subscribe to a Topic. Nodes can also provide or use a Service. There are configurable Parameters associated with a node. Connections between nodes are established through a distributed discovery process. Nodes may be located in the same process, in different processes, or on different machines. These concepts will be described in more detail in the sections that follow.
節點是ROS圖中的參與者。ROS節點使用ROS客戶端庫與其他節點通信。節點可以發布或訂閱主題。節點還可以提供或使用服務。可以對節點相關聯的參數進行配置。節點之間的連接是通過分布式發現過程建立的。節點可以位于相同的進程中,也可以位于不同的進程中,還可以位于不同的機器上。這些概念將在以下部分中更詳細地介紹說明。
Client Libraries?客戶端庫
ROS client libraries allow nodes written in different programming languages to communicate. There is a core ROS client library (RCL) that implements common functionality needed for the ROS APIs of different languages. This makes it so that language-specific client libraries are easier to write and that they have more consistent behavior.
ROS客戶端庫支持不同編程語言編寫的節點進行通信。一個核心的ROS客戶端庫(ROS client library, RCL)實現了不同語言ROS API所需的通用功能。這使得特定語言的客戶端庫更易于編寫,并且它們具有更一致的行為。
The following client libraries are maintained by the ROS 2 team:
以下客戶端庫由ROS 2團隊維護:
rclcpp = C++ client library
rclcpp = C ++客戶端庫
rclpy = Python client library
rclpy = Python客戶端庫
Additionally, other client libraries have been developed by the ROS community. See the?ROS 2 Client Libraries?article for more details.
此外,ROS社區還開發了其他客戶端庫。有關這方面內容的更多詳細信息,請參考ROS 2客戶端庫文章。
Discovery?消息發現機制
Discovery of nodes happens automatically through the underlying middleware of ROS 2. It can be summarized as follows:?節點的發現通過ROS 2的底層中間件自動實現完成。可以總結如下:
When a node is started, it advertises its presence to other nodes on the network with the same ROS domain (set with the ROS_DOMAIN_ID environment variable). Nodes respond to this advertisement with information about themselves so that the appropriate connections can be made and the nodes can communicate.
啟動節點時,它會將其存在通告給具有相同ROS域的網絡上的其他節點(使用ROS_DOMAIN_ID環境變量 設置ROS域)。節點使用有關自身的信息響應此通告,以便可以進行適當的連接并且節點可以進行通信。
Nodes periodically advertise their presence so that connections can be made with new-found entities, even after the initial discovery period.
節點定期通告其存在,以便即使在初始發現期之后也可以與新發現的實體建立連接。
Nodes advertise to other nodes when they go offline.
節點在離線時通告其他節點。
Nodes will only establish connections with other nodes if they have compatible?Quality of Service?settings.
只有節點具有兼容的服務質量設置,它們之間才可以建立連接。
Example: talker-listener?例如:發布器-訂閱器
In one terminal, start a node (written in C++) that will publish messages on a topic.
在一個終端中,啟動將在主題上發布消息的節點(用C ++編寫)。
ros2 run demo_nodes_cpp talker
In another terminal, start a second node (written in Python) that will subscribe to messages on the same topic.
在另一個終端中,啟動第二個節點(用Python編寫),該節點將訂閱同一主題的消息。
ros2 run demo_nodes_py listener
You should see that these nodes discover each other automatically, and begin to exchange messages.
如果運行正常,應該看到這些節點自動發現彼此,并開始交換消息。
多試幾組案例,熟練掌握ros2 run和rqt的基本使用。
任務調度
版權聲明:本文內容由網絡用戶投稿,版權歸原作者所有,本站不擁有其著作權,亦不承擔相應法律責任。如果您發現本站中有涉嫌抄襲或描述失實的內容,請聯系我們jiasou666@gmail.com 處理,核實后本網站將在24小時內刪除侵權內容。