From ff4e5bdb707702f71cab01b88f4e5dce5075a535 Mon Sep 17 00:00:00 2001 From: JohnSnowball Date: Mon, 20 Feb 2017 23:09:37 +0800 Subject: [PATCH 1/4] =?UTF-8?q?uorb=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 微信ID: 文火烧胸毛 --- advanced-uorb.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/advanced-uorb.md b/advanced-uorb.md index 905a4a1..71a5e10 100644 --- a/advanced-uorb.md +++ b/advanced-uorb.md @@ -1,6 +1,6 @@ -# uORB Messaging +# uORB 消息机制 -## Introduction +## 简介 The uORB is an asynchronous publish() / subscribe() messaging API used for inter-thread/inter-process communication. From 028ab01c14a4bacbe26a499c95cacbbdda44040a Mon Sep 17 00:00:00 2001 From: JohnSnowball Date: Tue, 21 Feb 2017 21:52:21 +0800 Subject: [PATCH 2/4] =?UTF-8?q?uORB=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- advanced-uorb.md | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/advanced-uorb.md b/advanced-uorb.md index 71a5e10..3e402f8 100644 --- a/advanced-uorb.md +++ b/advanced-uorb.md @@ -2,61 +2,59 @@ ## 简介 -The uORB is an asynchronous publish() / subscribe() messaging API used for -inter-thread/inter-process communication. +uORB(*微型对象请求代理*)是一个异步的发布/订阅消息机制的 API,用来实现线程或进程间的通讯。 -Look at the [tutorial](tutorial-hello-sky.md) to learn how to use it in C++. +请参照[教程](tutorial-hello-sky.md) 学习如何在 C++ 中使用该功能。 -uORB is automatically started early on bootup as many applications depend on it. -It is started with `uorb start`. Unit tests can be started with `uorb test`. +由于很多应用依赖该消息机制,uORB 会在系统启动时自动开始运行。 + `uorb start` 命令会启动该消息机制。使用 `uorb test` 命令可以启动单元测试。 -## Adding a new topic +## 添加一个新主题 -To add a new topic, you need to create a new `.msg` file in the `msg/` -directory and add the file name to the `msg/CMakeLists.txt` list. From this, -there will automatically be C/C++ code generated. +为了添加一个新主题,你需要在 `msg/` 路径下添加一个新的 `.msg` 文件,并将该文件名添加到 `msg/CMakeLists.txt` 列表中。通过以上步骤,系统将会自动生成 C/C++ 代码。 -Have a look at the existing `msg` files for supported types. A message can also -be used nested in other messages. -To each generated C/C++ struct, a field `uint64_t timestamp` will be added. This -is used for the logger, so make sure to fill it in when logging the message. +让我们来看看现有的 `msg` 文件所支持的类型。一条消息可以被嵌套在其他消息内。 +对于每一个生成的 C/C++ 结构,都会包含一个 `uint64_t timestamp` 成员。这个成员会被日志模块使用,所以如果要将消息记录进日志,请确保该成员被赋值。 + +要在代码中使用该消息,需要包含头文件: -To use the topic in the code, include the header: ``` #include ``` -By adding a line like the following in the `.msg` file, a single message -definition can be used for multiple independent topic instances: +在 `.msg` 文件中添加类似下面这一行,一条单一的消息定义可以被多个独立的主题实例使用。 + ``` # TOPICS mission offboard_mission onboard_mission ``` -Then in the code, use them as topic id: `ORB_ID(offboard_mission)`. +然后在代码中,通过如下的主题 ID 来使用新定义的主题: + `ORB_ID(offboard_mission)`. + +## 消息发布 (Publishing) -## Publishing +消息发布可以在系统的任何地方实现,包括中断上下文(通过 `hrt_call` API 调用的函数)。然而公告消息 (advertising) 则只能在中断上下文外部实现。在同一个进程中,一条主题被发布之前,必须先公告。 -Publishing a topic can be done from anywhere in the system, including interrupt context (functions called by the `hrt_call` API). However, advertising a topic is only possible outside of interrupt context. A topic has to be advertised in the same process as its later published. -## Listing Topics and Listening in +## 主题列表与监听 -To list all topics, list the file handles: +通过列出文件句柄来查看主题列表: ```sh ls /obj ``` -To listen to the content of one topic for 5 messages, run the listener: +调用 listener 来监听同一个主题的 5 条消息的内容: ```sh listener sensor_accel 5 ``` -The output is n-times the content of the topic: +输出为若干次该主题的内容: ```sh TOPIC: sensor_accel #3 @@ -87,3 +85,5 @@ temperature: 46 range_m_s2: 78 scaling: 0 ``` + + From e6db98d8b1b891ae9a4f641be7934e8d941b144b Mon Sep 17 00:00:00 2001 From: JohnSnowball Date: Tue, 21 Feb 2017 22:01:36 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=A1=8C=E6=95=B0?= =?UTF-8?q?=E4=B8=8E=E9=97=B4=E8=B7=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- advanced-uorb.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/advanced-uorb.md b/advanced-uorb.md index 3e402f8..0897b28 100644 --- a/advanced-uorb.md +++ b/advanced-uorb.md @@ -27,8 +27,7 @@ uORB(*微型对象请求代理*)是一个异步的发布/订阅消息机 ``` # TOPICS mission offboard_mission onboard_mission ``` -然后在代码中,通过如下的主题 ID 来使用新定义的主题: - `ORB_ID(offboard_mission)`. +然后在代码中,通过如下的主题 ID 来使用新定义的主题:`ORB_ID(offboard_mission)`. ## 消息发布 (Publishing) @@ -38,8 +37,7 @@ uORB(*微型对象请求代理*)是一个异步的发布/订阅消息机 ## 主题列表与监听 -