ROS2編程基礎課程--庫
About ROS2 client libraries
關于ROS2客戶端庫
Table of Contents?目錄
Overview?概述
Supported client libraries?支持的客戶端庫
Common functionality: the RCL?常用功能:RCL
Language-specific functionality?特定的語言功能
Demo?演示案例
Comparison to ROS 1?與ROS1的比較
Summary?總結
Overview?概述
Client libraries are the APIs that allow users to implement their ROS code. They are what users use to get access to ROS concepts such as nodes, topics, services, etc. Client libraries come in a variety of programming languages so that users may write ROS code in the language that is best-suited for their application. For example, you might prefer to write visualization tools in Python because it makes prototyping iterations faster, while for parts of your system that are concerned with efficiency, the nodes might be better implemented in C++.
客戶端庫是允許用戶實現其ROS代碼的API。它們是用戶用來訪問ROS概念(如節點、主題、服務等)的內容。客戶端庫有各種編程語言,因此用戶可以使用最適合其應用程序的語言編寫ROS代碼。例如,可能更喜歡在Python中編寫可視化工具,因為它可以更快地進行原型設計迭代,而對于系統中與效率相關的部分,可以在C ++中更好地實現節點。
Nodes written using different client libraries are able to share messages with each other because all client libraries implement code generators that provide users with the capability to interact with ROS interface files in the respective language.
使用不同客戶端庫編寫的節點能夠彼此共享消息,因為所有客戶端庫都實現了代碼生成器,這些代碼生成器為用戶提供了與相應語言的ROS接口文件交互的能力。
In addition to the language-specific communication tools, client libraries expose to users the core functionality that makes ROS “ROS”. For example, here is a list of functionality that can typically be accessed through a client library:
除了特定于語言的通信工具之外,客戶端庫還向用戶展示了使ROS成為“ROS”的核心功能。例如,以下是通常可以通過客戶端庫訪問的功能列表:
Names and namespaces?命名和命名空間
Time (real or simulated)?時間(真實或模擬)
Parameters?參數
Console logging?控制臺記錄
Threading model?線程模型
Intra-process communication?進程內通信
Supported client libraries?支持的客戶端庫
The C++ client library (rclcpp) and the Python client library (rclpy) are both client libraries which utilize common functionality in the RCL.
C ++客戶端庫(rclcpp)和Python客戶端庫(rclpy)都是RCL中常見功能的客戶端庫。
While the C++ and Python client libraries are maintained by the core ROS 2 team, members of the ROS 2 community have created additional client libraries:
雖然C ++和Python客戶端庫由核心ROS 2團隊維護,但ROS 2社區的成員已創建了其他客戶端庫:
JVM and Android
Objective C and iOS
C#
Swift
Node.js
Ada
_.NET Core, UWP and C#
Common functionality: the RCL?常用功能:RCL
Most of the functionality found in a client library is not specific to the programming language of the client library. For example, the behavior of parameters and the logic of namespaces should ideally be the same across all programming languages. Because of this, rather than implementing the common functionality from scratch, client libraries make use of a common core ROS Client Library (RCL) interface that implements logic and behavior of ROS concepts that is not language-specific. As a result, client libraries only need to wrap the common functionality in the RCL with foreign function interfaces. This keeps client libraries thinner and easier to develop. For this reason the common RCL functionality is exposed with C interfaces as the C language is typically the easiest language for client libraries to wrap.
客戶端庫中的大多數功能并非特定于客戶端庫的編程語言。例如,參數的行為和命名空間的邏輯在理想情況下應該在所有編程語言中都是相同的。因此,客戶端庫不是從頭開始實現通用功能,而是使用通用核心ROS客戶端庫(RCL)接口,該接口實現非特定語言的ROS概念的邏輯和行為。因此,客戶端庫只需要使用外部函數接口封裝RCL中的公共功能。這使客戶端庫更透明(薄),更容易開發。因此,C語言通常是用于客戶端庫封裝的最簡單的語言,因此公共RCL功能通過C接口公開。
In addition to making the client libraries light-weight, an advantage of having the common core is that the behavior between languages is more consistent. If any changes are made to the logic/behavior of the functionality in the core RCL – namespaces, for example – all client libraries that use the RCL will have these changes reflected. Furthermore, having the common core means that maintaining multiple client libraries becomes less work when it comes to bug fixes.
除了使客戶端庫輕量化之外,擁有共同核心的一個優點是語言之間的行為更加一致。如果對核心RCL中的功能的邏輯/行為進行任何更改-例如,命名空間-所有使用RCL的客戶端庫都會反映這些更改。此外,擁有通用核心意味著在修復錯誤時,維護多個客戶端庫的工作量會減少。
The API documentation for the RCL can be found here.?可以在此處找到RCL的API文檔。
Language-specific functionality?語言特定功能
Client library concepts that require language-specific features/properties are not implemented in the RCL but instead are implemented in each client library. For example, threading models used by “spin” functions will have implementations that are specific to the language of the client library.
需要特定于語言的功能/屬性的客戶端庫概念未在RCL中實現,而是在每個客戶端庫中實現。例如,“spin”函數使用的線程模型將具有特定于客戶端庫的語言的實現。
Demo?演示實例
For a walkthrough of the message exchange between a publisher using?rclpy?and a subscriber using?rclcpp, we encourage you to watch?this ROSCon talk?starting at 17:25?(here are the slides).
有關發布器使用rclpy和訂閱器使用之間的消息交換的演練rclcpp,我們建議您從17:25開始觀看此ROSCon演講(這是幻燈片講稿)。
Comparison to ROS 1?與ROS 1的比較
In ROS 1, all client libraries are developed “from the ground up”. This allows for the ROS 1 Python client library to be implemented purely in Python, for example, which brings benefits of such as not needing to compile code. However, naming conventions and behaviors are not always consistent between client libraries, bug fixes have to be done in multiple places, and there is a lot of functionality that has only ever been implemented in one client library (e.g. UDPROS).
在ROS 1中,所有客戶端庫都是“從頭開始”開發的。例如,這允許ROS 1 Python客戶端庫純粹用Python實現,這帶來了諸如不需要編譯代碼等好處。但是,命名約定和行為在客戶端庫之間并不總是一致的,錯誤修復必須在多個位置完成,并且有許多功能只在一個客戶端庫(例如UDPROS)中實現。
Summary?摘要
By utilizing the common core ROS client library, client libraries written in a variety of programming languages are easier to write and have more consistent behavior.
通過使用通用核心ROS客戶端庫,使各種編程語言編寫的客戶端庫更易于編寫并具有更一致的行為。
Python
版權聲明:本文內容由網絡用戶投稿,版權歸原作者所有,本站不擁有其著作權,亦不承擔相應法律責任。如果您發現本站中有涉嫌抄襲或描述失實的內容,請聯系我們jiasou666@gmail.com 處理,核實后本網站將在24小時內刪除侵權內容。