text: (window.webpackJsonp=window.webpackJsonp||[]).push([[692],{1207:function(t,s,a){t.exports=a.p+"assets/img/architecture.94eff761.png"},2607:function(t,s,a){"use strict";a.r(s);var e=a(19),n=Object(e.a)({},(function(){var t=this,s=t.$createElement,e=t._self._c||s;return e("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[e("h1",{attrs:{id:"rtps-ros2-接口-px4-fastrtps桥接"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#rtps-ros2-接口-px4-fastrtps桥接"}},[t._v("#")]),t._v(" RTPS/ROS2 接口：PX4-FastRTPS桥接")]),t._v(" "),e("p",[t._v("The "),e("em",[t._v("PX4-Fast RTPS(DDS) Bridge")]),t._v(", which is also referred to as as the "),e("em",[t._v("microRTPS Bridge")]),t._v(", adds a Real Time Publish Subscribe (RTPS) interface to the PX4 Autopilot, enabling the exchange of "),e("RouterLink",{attrs:{to:"/zh/middleware/uorb.html"}},[t._v("uORB messages")]),t._v(" between the various PX4 Autopilot internal components and (offboard) "),e("em",[t._v("Fast DDS")]),t._v(" applications in realtime.")],1),t._v(" "),e("p",[t._v("This allows us to better integrate with applications running and linked in DDS domains (including ROS nodes), making it easy to share sensor data, commands, and other vehicle information.")]),t._v(" "),e("p",[t._v("The following guide describes the RTPS/DDS bridge architecture, and shows the reader how to write a simple "),e("em",[t._v("Fast DDS")]),t._v(" application to subscribe to telemetry updates from the PX4 Autopilot.")]),t._v(" "),e("p",[t._v("当您需要在飞行控制器和offboard部件之间可靠地共享时间敏感/实时信息时, 应使用RTPS。 特别是, 在off-board软件需要 (通过发送和接收 uORB主题) 成为 px4 中运行的软件组件的 "),e("em",[t._v("伙伴")]),t._v(" 的情况下，它非常有用。")]),t._v(" "),e("p",[e("em",[t._v("Fast DDS")]),t._v(" is a very lightweight cross-platform implementation of the latest version of the RTPS protocol / DDS middleware.  It was previously named "),e("em",[t._v("Fast RTPS")]),t._v(".\n:::")]),t._v(" "),e("h2",{attrs:{id:"什么时候应该使用-rtps"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#什么时候应该使用-rtps"}},[t._v("#")]),t._v(" 什么时候应该使用 RTPS？")]),t._v(" "),e("p",[t._v("RTPS should be used when you need to reliably share time-critical/real-time information between the flight controller and offboard components. It is instrumental in cases where offboard software needs to become a "),e("em",[t._v("peer")]),t._v(" of software components running in PX4 (sending and receiving uORB topics).")]),t._v(" "),e("p",[t._v("Possible use cases include communicating with robotics libraries for computer vision and other use cases where real-time data to/from actuators and sensors is essential for vehicle control.")]),t._v(" "),e("p",[e("em",[t._v("Fast DDS")]),t._v(" is not intended as a replacement for MAVLink. "),e("RouterLink",{attrs:{to:"/zh/middleware/mavlink.html"}},[t._v("MAVLink")]),t._v(" remains the most appropriate protocol for communicating with ground stations, gimbals, cameras, and other offboard components (although "),e("em",[t._v("Fast DDS")]),t._v(" may open other opportunities for working with some peripherals at higher frequencies).")],1),t._v(" "),e("div",{staticClass:"custom-block tip"},[e("p",{staticClass:"custom-block-title"},[t._v("提示")]),t._v(" "),e("p",[t._v("It is possible to use Fast RTPS(DDS) over slower links (e.g., radio telemetry) by being mindful of your link's extra constraints. Keep in mind you can easily overload your telemetry channel.")])]),t._v(" "),e("h2",{attrs:{id:"架构概述"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#架构概述"}},[t._v("#")]),t._v(" 架构概述")]),t._v(" "),e("h3",{attrs:{id:"rtps-桥接"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#rtps-桥接"}},[t._v("#")]),t._v(" RTPS 桥接")]),t._v(" "),e("p",[t._v("The "),e("em",[t._v("microRTPS")]),t._v(" bridge exchanges messages between PX4 and DDS-participant applications, seamlessly converting between the "),e("RouterLink",{attrs:{to:"/zh/middleware/uorb.html"}},[t._v("uORB")]),t._v(" and RTPS/DDS messages used by each system.")],1),t._v(" "),e("p",[e("img",{attrs:{src:a(1207),alt:"basic example flow"}})]),t._v(" "),e("p",[t._v("The main elements of the architecture are the client and agent processes shown in the diagram above.")]),t._v(" "),e("h4",{attrs:{id:"the-micrortps-client"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#the-micrortps-client"}},[t._v("#")]),t._v(" The microRTPS Client")]),t._v(" "),e("p",[t._v("The "),e("em",[t._v("Client")]),t._v(" is the PX4 Autopilot middleware daemon process that runs on the flight controller. This client subscribes to uORB topics published by other PX4 Autopilot components and sends any updates to the "),e("em",[t._v("Agent")]),t._v(" (via a UART or UDP port), and also receives messages from the "),e("em",[t._v("Agent")]),t._v(" and publishes them as uORB messages to the PX4 Autopilot.")]),t._v(" "),e("h4",{attrs:{id:"the-micrortps-agent"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#the-micrortps-agent"}},[t._v("#")]),t._v(" The microRTPS Agent")]),t._v(" "),e("p",[t._v("The "),e("em",[t._v("Agent")]),t._v(" runs as a daemon process on an offboard computer (outside the flight controller). This agent watches for uORB update messages from the "),e("em",[t._v("Client")]),t._v(' and (re)publishes them over RTPS, and also subscribes to "uORB" RTPS/DDS messages from other DDS-participant applications and forwards them to the '),e("em",[t._v("Client")]),t._v(".")]),t._v(" "),e("h4",{attrs:{id:"micrortps-agent-client-communication"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#micrortps-agent-client-communication"}},[t._v("#")]),t._v(" microRTPS Agent/Client Communication")]),t._v(" "),e("p",[t._v("The "),e("em",[t._v("Agent")]),t._v(" and "),e("em",[t._v("Client")]),t._v(" are connected via a serial link (UART) or UDP network, and the uORB information is "),e("a",{attrs:{href:"https://en.wikipedia.org/wiki/Common_Data_Representation",target:"_blank",rel:"noopener noreferrer"}},[t._v("CDR serialized"),e("OutboundLink")],1),t._v(" before being sent ("),e("em",[t._v("CDR serialization")]),t._v(" provides a common format for exchanging serial data between different platforms).")]),t._v(" "),e("p",[t._v("The "),e("em",[t._v("Agent")]),t._v(" and any "),e("em",[t._v("Fast DDS")]),t._v(" applications are connected via UDP and may be on the same or another device. In a typical configuration, they will be on the same system (e.g., a development computer, Linux companion computer, or compute board), connected to the "),e("em",[t._v("Client")]),t._v(". This can be through a Wifi link or USB.")]),t._v(" "),e("h2",{attrs:{id:"代码生成"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#代码生成"}},[t._v("#")]),t._v(" 代码生成")]),t._v(" "),e("h3",{attrs:{id:"ros2-ros-应用处理流程"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#ros2-ros-应用处理流程"}},[t._v("#")]),t._v(" ROS2/ROS 应用处理流程")]),t._v(" "),e("p",[t._v("Fast DDS 2.0.0 or later and Fast-RTPS-Gen 1.0.4 (not later!) must be installed in order to generate the required code, and continue to the next steps. "),e("RouterLink",{attrs:{to:"/zh/dev_setup/fast-dds-installation.html"}},[t._v("Follow the installation guide.")])],1),t._v(" "),e("div",{staticClass:"custom-block note"},[e("p",{staticClass:"custom-block-title"},[t._v("RTPS")]),t._v(" "),e("p",[t._v("has been adopted as the middleware for the ROS 2 (Robot Operating System).")]),t._v(" "),e("p",[t._v("For information about how to use this interface within the ROS 2 applications and development workflows, see "),e("RouterLink",{attrs:{to:"/zh/ros/ros2_comm.html"}},[t._v("PX4-ROS 2 bridge")]),t._v(".")],1)]),t._v(" "),e("h3",{attrs:{id:"独立于-ros-的应用程序"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#独立于-ros-的应用程序"}},[t._v("#")]),t._v(" 独立于 ROS 的应用程序")]),t._v(" "),e("p",[t._v("All the code needed to create, build and use the bridge is automatically generated when PX4-Autopilot is compiled.")]),t._v(" "),e("p",[t._v("The "),e("em",[t._v("Client")]),t._v(" application is also compiled and built into the firmware as part of the normal build process. The "),e("em",[t._v("Agent")]),t._v(" must be separately/manually compiled for the target computer.")]),t._v(" "),e("div",{staticClass:"custom-block tip"},[e("p",{staticClass:"custom-block-title"},[t._v("提示")]),t._v(" "),e("p",[t._v("Most users will not need to do so. Still, the bridge can be "),e("RouterLink",{attrs:{to:"/zh/middleware/micrortps_manual_code_generation.html"}},[t._v("manually generated")]),t._v(", providing a more detailed overview of the build process and useful for troubleshooting.")],1)]),t._v(" "),e("h2",{attrs:{id:"支持的-uorb-消息"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#支持的-uorb-消息"}},[t._v("#")]),t._v(" 支持的 uORB 消息")]),t._v(" "),e("p",[t._v("The generated bridge code will enable a specified subset of uORB topics to be published/subscribed via RTPS, regardless if you are deploying a ROS application or not.")]),t._v(" "),e("p",[t._v("For "),e("em",[t._v("automatic code generation")]),t._v(" there's a "),e("em",[t._v("yaml")]),t._v(" definition file in the PX4 "),e("strong",[t._v("PX4-Autopilot/msg/tools/")]),t._v(" directory called "),e("strong",[t._v("uorb_rtps_message_ids.yaml")]),t._v(". This file defines the set of uORB messages to be used with RTPS, whether the messages are to be sent, received or both, and the RTPS ID for the message to be used in DDS/RTPS middleware.")]),t._v(" "),e("div",{staticClass:"custom-block note"},[e("p",{staticClass:"custom-block-title"},[t._v("注解")]),t._v(" "),e("p",[t._v("It's essential to note that every RTPS message "),e("strong",[t._v("needs")]),t._v(" an ID to be set in this file.")])]),t._v(" "),e("div",{staticClass:"language-yaml extra-class"},[e("pre",{pre:!0,attrs:{class:"language-yaml"}},[e("code",[e("span",{pre:!0,attrs:{class:"token key atrule"}},[t._v("rtps")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v("\n  "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("-")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token key atrule"}},[t._v("msg")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" actuator_armed\n    "),e("span",{pre:!0,attrs:{class:"token key atrule"}},[t._v("id")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("0")]),t._v("\n  "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("-")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token key atrule"}},[t._v("msg")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" actuator_control\n    "),e("span",{pre:!0,attrs:{class:"token key atrule"}},[t._v("id")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("1")]),t._v("\n  "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("-")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("...")]),t._v("\n  "),e("span",{pre:!0,attrs:{class:"token key atrule"}},[t._v("rtps")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v("\n  "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("-")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token key atrule"}},[t._v("msg")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" actuator_armed\n    "),e("span",{pre:!0,attrs:{class:"token key atrule"}},[t._v("id")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("0")]),t._v("\n  "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("-")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token key atrule"}},[t._v("msg")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" actuator_control\n    "),e("span",{pre:!0,attrs:{class:"token key atrule"}},[t._v("id")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("1")]),t._v("\n  "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("-")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("...")]),t._v("\n  "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("-")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token key atrule"}},[t._v("msg")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" airspeed\n    "),e("span",{pre:!0,attrs:{class:"token key atrule"}},[t._v("id")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("5")]),t._v("\n    "),e("span",{pre:!0,attrs:{class:"token key atrule"}},[t._v("send")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token boolean important"}},[t._v("true")]),t._v("\n  "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("-")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token key atrule"}},[t._v("msg")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" battery_status\n    "),e("span",{pre:!0,attrs:{class:"token key atrule"}},[t._v("id")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("6")]),t._v("\n    "),e("span",{pre:!0,attrs:{class:"token key atrule"}},[t._v("send")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token boolean important"}},[t._v("true")]),t._v("\n  "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("-")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token key atrule"}},[t._v("msg")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" camera_capture\n    "),e("span",{pre:!0,attrs:{class:"token key atrule"}},[t._v("id")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("7")]),t._v("\n  "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("-")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token key atrule"}},[t._v("msg")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" camera_trigger\n    "),e("span",{pre:!0,attrs:{class:"token key atrule"}},[t._v("id")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("8")]),t._v("\n    "),e("span",{pre:!0,attrs:{class:"token key atrule"}},[t._v("receive")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token boolean important"}},[t._v("true")]),t._v("\n  "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("-")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("...")]),t._v("\n  "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("-")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token key atrule"}},[t._v("msg")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" sensor_baro\n    "),e("span",{pre:!0,attrs:{class:"token key atrule"}},[t._v("id")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("63")]),t._v("\n    "),e("span",{pre:!0,attrs:{class:"token key atrule"}},[t._v("receive")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token boolean important"}},[t._v("true")]),t._v("\n    "),e("span",{pre:!0,attrs:{class:"token key atrule"}},[t._v("send")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token boolean important"}},[t._v("true")]),t._v("\n  "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("-")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token key atrule"}},[t._v("msg")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" sensor_baro\n    "),e("span",{pre:!0,attrs:{class:"token key atrule"}},[t._v("id")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("63")]),t._v("\n    "),e("span",{pre:!0,attrs:{class:"token key atrule"}},[t._v("receive")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token boolean important"}},[t._v("true")]),t._v("\n    "),e("span",{pre:!0,attrs:{class:"token key atrule"}},[t._v("send")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token boolean important"}},[t._v("true")]),t._v("\n")])])]),e("p",[e("a",{attrs:{id:"client_firmware"}})]),t._v(" "),e("h2",{attrs:{id:"客户端-px4固件"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#客户端-px4固件"}},[t._v("#")]),t._v(" 客户端 (PX4固件)")]),t._v(" "),e("p",[t._v("The "),e("em",[t._v("Client")]),t._v(" source code is generated, compiled and built into the PX4 Autopilot firmware as part of the normal build process.")]),t._v(" "),e("p",[t._v("To build the PX4 Autopilot firmware for NuttX/Pixhawk flight controllers use the "),e("code",[t._v("_rtps")]),t._v(" feature in the configuration target.")]),t._v(" "),e("p",[t._v("For example, to build RTPS for px4_fmu-v4:")]),t._v(" "),e("div",{staticClass:"language-sh extra-class"},[e("pre",{pre:!0,attrs:{class:"language-sh"}},[e("code",[e("span",{pre:!0,attrs:{class:"token function"}},[t._v("make")]),t._v(" px4_fmu-v4_rtps\n")])])]),e("p",[t._v("To build the firmware for a SITL target:")]),t._v(" "),e("div",{staticClass:"language-sh extra-class"},[e("pre",{pre:!0,attrs:{class:"language-sh"}},[e("code",[e("span",{pre:!0,attrs:{class:"token function"}},[t._v("make")]),t._v(" px4_sitl_rtps\n")])])]),e("p",[t._v("The "),e("em",[t._v("Client")]),t._v(" application can be launched from "),e("RouterLink",{attrs:{to:"/zh/debug/system_console.html"}},[t._v("NuttShell/System Console")]),t._v(". The command syntax is shown below (you can specify a variable number of arguments):")],1),t._v(" "),e("div",{staticClass:"language-sh extra-class"},[e("pre",{pre:!0,attrs:{class:"language-sh"}},[e("code",[e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">")]),t._v(" micrortps_client start"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("|")]),t._v("stop "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("options"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v("\n  -t "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&")]),t._v("lt"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("transport"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&")]),t._v("gt"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("          "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("UART"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("|")]),t._v("UDP"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v(" 缺省为 UART\n  -d "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&")]),t._v("lt"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("device"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&")]),t._v("gt"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("             UART 设备. 缺省为 /dev/ttyACM0\n  -u "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&")]),t._v("lt"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("update_time_ms"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&")]),t._v("gt"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("     订阅的 uORB 消息的刷新时间，单位ms。 缺省为 "),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("0")]),t._v("\n  -l "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&")]),t._v("lt"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("loops"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&")]),t._v("gt"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("              该程序将循环执行多少次。 Default /dev/ttyACM0\n  -l "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<")]),t._v("loops"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">")]),t._v("              How many iterations will this program have. -1 表示无限循环， 缺省为 -1。 缺省为 -1。\n  -w "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&")]),t._v("lt"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("sleep_time_us"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&")]),t._v("gt"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("      每次循环的休眠时间，单位us。 缺省为 1ms\n  -b "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&")]),t._v("lt"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("baudrate"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&")]),t._v("gt"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("           UART 设备波特率 缺省为 "),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("460800")]),t._v("\n  -p "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&")]),t._v("lt"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("poll_ms"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&")]),t._v("gt"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("            UART设备轮询时间，单位ms， 缺省为 1ms\n  -r "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&")]),t._v("lt"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("reception port"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&")]),t._v("gt"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("     UDP接收端口号， -r "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&")]),t._v("lt"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("reception port"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&")]),t._v("gt"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("     UDP 接收端口， 缺省为 "),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("2019")]),t._v("。 -s "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&")]),t._v("lt"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("sending port"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&")]),t._v("gt"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("       UDP发送端口， 缺省为 "),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("2020")]),t._v("。 Default "),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("2020")]),t._v("\n  -i "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<")]),t._v("ip_address"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">")]),t._v("         Select IP address "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("remote"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" values: "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<")]),t._v("x.x.x.x"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">")]),t._v(". Default: "),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("127.0")]),t._v(".0.1\n")])])]),e("p",[t._v("为了构建 "),e("em",[t._v("Agent")]),t._v(" 应用, 运行如下编译命令:")]),t._v(" "),e("p",[t._v("The PX4 Autopilot firmware initialization code may in future automatically start the "),e("em",[t._v("Client")]),t._v(" as a permanent daemon process.\n:::")]),t._v(" "),e("p",[t._v("要在一台 Ubuntu 18.04 机器上安装 ROS Melodic 和 ROS2 Bouncy, 分别参考如下链接:")]),t._v(" "),e("div",{staticClass:"language-sh extra-class"},[e("pre",{pre:!0,attrs:{class:"language-sh"}},[e("code",[t._v("micrortps_client start -t UDP\n")])])]),e("h2",{attrs:{id:"与-ros-无关的-offboard-fast-rtps-接口中的代理端"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#与-ros-无关的-offboard-fast-rtps-接口中的代理端"}},[t._v("#")]),t._v(" 与 ROS 无关的 Offboard Fast RTPS 接口中的代理端")]),t._v(" "),e("p",[t._v("The "),e("em",[t._v("Agent")]),t._v(" code is automatically "),e("em",[t._v("generated")]),t._v(" when you build the associated PX4 Autopilot firmware, and you can find the source here: "),e("code",[t._v("build/<target-platform>/src/modules/micrortps_bridge/micrortps_client/micrortps_agent/")]),t._v(".")]),t._v(" "),e("p",[t._v("To build the "),e("em",[t._v("Agent")]),t._v(" application, compile the code:")]),t._v(" "),e("div",{staticClass:"language-sh extra-class"},[e("pre",{pre:!0,attrs:{class:"language-sh"}},[e("code",[e("span",{pre:!0,attrs:{class:"token builtin class-name"}},[t._v("cd")]),t._v(" build/"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<")]),t._v("target-platform"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">")]),t._v("/src/modules/micrortps_bridge/micrortps_client/micrortps_agent\n"),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("mkdir")]),t._v(" build "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&&")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token builtin class-name"}},[t._v("cd")]),t._v(" build\ncmake "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("..")]),t._v("\n"),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("make")]),t._v("\n"),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("make")]),t._v("\n")])])]),e("p",[t._v("The command syntax for the "),e("em",[t._v("Agent")]),t._v(" is listed below:")]),t._v(" "),e("div",{staticClass:"language-sh extra-class"},[e("pre",{pre:!0,attrs:{class:"language-sh"}},[e("code",[t._v("$ ./micrortps_agent "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("options"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v("\n  -t "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&")]),t._v("lt"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("transport"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&")]),t._v("gt"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("          "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("UART"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("|")]),t._v("UDP"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v(" 缺省为UART.\n  -d "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&")]),t._v("lt"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("device"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&")]),t._v("gt"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("             UART设备， 缺省为 /dev/ttyACM0。\n  -d "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&")]),t._v("lt"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("device"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&")]),t._v("gt"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("             UART设备， 缺省为 /dev/ttyACM0。\n  -w "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&")]),t._v("lt"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("sleep_time_us"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&")]),t._v("gt"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("      每次循环的休眠时间，单位us。 默认 1ms。\n  -b "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&")]),t._v("lt"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("baudrate"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&")]),t._v("gt"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("           UART设备波特率。 默认 "),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("460800")]),t._v("。\n  -p "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&")]),t._v("lt"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("poll_ms"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&")]),t._v("gt"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("            UART设备轮询时间，单位ms， 缺省为 1ms。 缺省为 1ms。\n  -r "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&")]),t._v("lt"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("reception port"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&")]),t._v("gt"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("     UDP 接收端口， 缺省为 "),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("2019")]),t._v("。\n  -s "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&")]),t._v("lt"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("sending port"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&")]),t._v("gt"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("       UDP发送端口， 缺省为 "),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("2020")]),t._v("。\n  -n "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<")]),t._v("set namespace"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">")]),t._v("      Set a namespace "),e("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("for")]),t._v(" the micrortps_agent.\n")])])]),e("p",[t._v("To launch the "),e("em",[t._v("Agent")]),t._v(", run "),e("code",[t._v("micrortps_agent")]),t._v(" with appropriate options for specifying the connection to the "),e("em",[t._v("Client")]),t._v(" (the default options connect from a Linux device to the "),e("em",[t._v("Client")]),t._v(" over a UART port).")]),t._v(" "),e("p",[t._v("As an example, to start the "),e("em",[t._v("micrortps_agent")]),t._v(" with connection through UDP, issue:")]),t._v(" "),e("div",{staticClass:"language-sh extra-class"},[e("pre",{pre:!0,attrs:{class:"language-sh"}},[e("code",[t._v("./micrortps_agent -t UDP\n")])])]),e("h2",{attrs:{id:"面向-ros2-中间件的代理端接口"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#面向-ros2-中间件的代理端接口"}},[t._v("#")]),t._v(" 面向 ROS2 中间件的代理端接口")]),t._v(" "),e("p",[t._v("Once the "),e("em",[t._v("Client")]),t._v(" (on the flight controller) and the "),e("em",[t._v("Agent")]),t._v(" (on an offboard computer) are running and connected, "),e("em",[t._v("Fast DDS")]),t._v(" applications can publish and subscribe to uORB topics on the PX4 Autopilot using RTPS.")]),t._v(" "),e("p",[t._v("This example shows how to create a "),e("em",[t._v("Fast DDS")]),t._v(' "listener" application that subscribes to the '),e("code",[t._v("sensor_combined")]),t._v(" topic and prints out updates published from the PX4 Autopilot. A connected RTPS application can run on any computer on the same network as the "),e("em",[t._v("Agent")]),t._v(". For this example the "),e("em",[t._v("Agent")]),t._v(" and "),e("em",[t._v("Listener application")]),t._v(" will be on the same computer.")]),t._v(" "),e("p",[t._v("The "),e("em",[t._v("fastrtpsgen")]),t._v(" script can be used to generate a simple RTPS application from an IDL message file.")]),t._v(" "),e("p",[t._v("一旦 "),e("em",[t._v("Client")]),t._v(" (在飞行控制器上) 和 "),e("em",[t._v("Agent")]),t._v(" (在一台 offboard 计算机上) 同时运行并且成功互联, "),e("em",[t._v("Fast RTPS")]),t._v(" 应用就可以通过 RTPS 发布或订阅PX4 上的 uORB 消息。")]),t._v(" "),e("p",[t._v("When building the bridge code, IDL files are generated for the uORB messages that may be sent/received, these IDL files are needed when you create a Fast DDS application to communicate with the PX4 Autopilot.")]),t._v(" "),e("p",[t._v("You can find them in following path per build target: "),e("strong",[t._v("build/BUILDPLATFORM/src/modules/micrortps_bridge/micrortps_agent/idl/*.idl")]),t._v(".\n:::")]),t._v(" "),e("p",[t._v("Enter the following commands to create the application:")]),t._v(" "),e("div",{staticClass:"language-sh extra-class"},[e("pre",{pre:!0,attrs:{class:"language-sh"}},[e("code",[e("span",{pre:!0,attrs:{class:"token builtin class-name"}},[t._v("cd")]),t._v(" /path/to/PX4/PX4-Autopilot\n"),e("span",{pre:!0,attrs:{class:"token builtin class-name"}},[t._v("cd")]),t._v(" build/px4_sitl_rtps/src/modules/micrortps_bridge\n"),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("mkdir")]),t._v(" micrortps_listener\n"),e("span",{pre:!0,attrs:{class:"token builtin class-name"}},[t._v("cd")]),t._v(" micrortps_listener\nfastrtpsgen -example x64Linux2.6gcc "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("..")]),t._v("/micrortps_agent/idl/sensor_combined.idl\n")])])]),e("p",[t._v("This creates a basic subscriber and publisher, and a main-application that you can run. In order to print the data from the "),e("code",[t._v("sensor_combined")]),t._v(" topic, modify the "),e("code",[t._v("onNewDataMessage()")]),t._v(" method in "),e("strong",[t._v("sensor_combined_Subscriber.cxx")]),t._v(":")]),t._v(" "),e("div",{staticClass:"language-cpp extra-class"},[e("pre",{pre:!0,attrs:{class:"language-cpp"}},[e("code",[e("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("void")]),t._v(" sensor_combined_Subscriber"),e("span",{pre:!0,attrs:{class:"token double-colon punctuation"}},[t._v("::")]),e("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("SubListener")]),e("span",{pre:!0,attrs:{class:"token double-colon punctuation"}},[t._v("::")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("onNewDataMessage")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("Subscriber"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("*")]),t._v(" sub"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n    "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// Take data")]),t._v("\n    sensor_combined_ st"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n\n    "),e("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("if")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("sub"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("->")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("takeNextData")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&")]),t._v("st"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&")]),t._v("m_info"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n    "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n        "),e("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("if")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("m_info"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("sampleKind "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("==")]),t._v(" ALIVE"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n        "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n            "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// Print your structure data here.")]),t._v("\n            "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("++")]),t._v("n_msg"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n            std"),e("span",{pre:!0,attrs:{class:"token double-colon punctuation"}},[t._v("::")]),t._v("cout "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token string"}},[t._v('"\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n"')]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n            std"),e("span",{pre:!0,attrs:{class:"token double-colon punctuation"}},[t._v("::")]),t._v("cout "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token string"}},[t._v('"Sample received, count="')]),t._v(" "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" n_msg "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" std"),e("span",{pre:!0,attrs:{class:"token double-colon punctuation"}},[t._v("::")]),t._v("endl"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n            std"),e("span",{pre:!0,attrs:{class:"token double-colon punctuation"}},[t._v("::")]),t._v("cout "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token string"}},[t._v('"============================="')]),t._v(" "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" std"),e("span",{pre:!0,attrs:{class:"token double-colon punctuation"}},[t._v("::")]),t._v("endl"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n            std"),e("span",{pre:!0,attrs:{class:"token double-colon punctuation"}},[t._v("::")]),t._v("cout "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token string"}},[t._v('"gyro_rad: "')]),t._v(" "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" st"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("gyro_rad")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("at")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("0")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n            std"),e("span",{pre:!0,attrs:{class:"token double-colon punctuation"}},[t._v("::")]),t._v("cout "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token string"}},[t._v('", "')]),t._v(" "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" st"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("gyro_rad")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("at")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("1")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n            std"),e("span",{pre:!0,attrs:{class:"token double-colon punctuation"}},[t._v("::")]),t._v("cout "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token string"}},[t._v('", "')]),t._v(" "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" st"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("gyro_rad")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("at")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("2")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" std"),e("span",{pre:!0,attrs:{class:"token double-colon punctuation"}},[t._v("::")]),t._v("endl"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n            std"),e("span",{pre:!0,attrs:{class:"token double-colon punctuation"}},[t._v("::")]),t._v("cout "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token string"}},[t._v('"gyro_integral_dt: "')]),t._v(" "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" st"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("gyro_integral_dt")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" std"),e("span",{pre:!0,attrs:{class:"token double-colon punctuation"}},[t._v("::")]),t._v("endl"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n            std"),e("span",{pre:!0,attrs:{class:"token double-colon punctuation"}},[t._v("::")]),t._v("cout "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token string"}},[t._v('"accelerometer_timestamp_relative: "')]),t._v(" "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" st"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("accelerometer_timestamp_relative")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" std"),e("span",{pre:!0,attrs:{class:"token double-colon punctuation"}},[t._v("::")]),t._v("endl"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n            std"),e("span",{pre:!0,attrs:{class:"token double-colon punctuation"}},[t._v("::")]),t._v("cout "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token string"}},[t._v('"accelerometer_m_s2: "')]),t._v(" "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" st"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("accelerometer_m_s2")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("at")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("0")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n            std"),e("span",{pre:!0,attrs:{class:"token double-colon punctuation"}},[t._v("::")]),t._v("cout "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token string"}},[t._v('", "')]),t._v(" "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" st"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("accelerometer_m_s2")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("at")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("1")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n            std"),e("span",{pre:!0,attrs:{class:"token double-colon punctuation"}},[t._v("::")]),t._v("cout "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token string"}},[t._v('", "')]),t._v(" "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" st"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("accelerometer_m_s2")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("at")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("2")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" std"),e("span",{pre:!0,attrs:{class:"token double-colon punctuation"}},[t._v("::")]),t._v("endl"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n            std"),e("span",{pre:!0,attrs:{class:"token double-colon punctuation"}},[t._v("::")]),t._v("cout "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token string"}},[t._v('"accelerometer_integral_dt: "')]),t._v(" "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" st"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("accelerometer_integral_dt")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" std"),e("span",{pre:!0,attrs:{class:"token double-colon punctuation"}},[t._v("::")]),t._v("endl"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n            std"),e("span",{pre:!0,attrs:{class:"token double-colon punctuation"}},[t._v("::")]),t._v("cout "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token string"}},[t._v('"magnetometer_timestamp_relative: "')]),t._v(" "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" st"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("magnetometer_timestamp_relative")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" std"),e("span",{pre:!0,attrs:{class:"token double-colon punctuation"}},[t._v("::")]),t._v("endl"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n            std"),e("span",{pre:!0,attrs:{class:"token double-colon punctuation"}},[t._v("::")]),t._v("cout "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token string"}},[t._v('"magnetometer_ga: "')]),t._v(" "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" st"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("magnetometer_ga")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("at")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("0")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n            std"),e("span",{pre:!0,attrs:{class:"token double-colon punctuation"}},[t._v("::")]),t._v("cout "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token string"}},[t._v('", "')]),t._v(" "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" st"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("magnetometer_ga")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("at")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("1")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n            std"),e("span",{pre:!0,attrs:{class:"token double-colon punctuation"}},[t._v("::")]),t._v("cout "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token string"}},[t._v('", "')]),t._v(" "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" st"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("magnetometer_ga")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("at")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("2")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" std"),e("span",{pre:!0,attrs:{class:"token double-colon punctuation"}},[t._v("::")]),t._v("endl"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n            std"),e("span",{pre:!0,attrs:{class:"token double-colon punctuation"}},[t._v("::")]),t._v("cout "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token string"}},[t._v('"baro_timestamp_relative: "')]),t._v(" "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" st"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("baro_timestamp_relative")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" std"),e("span",{pre:!0,attrs:{class:"token double-colon punctuation"}},[t._v("::")]),t._v("endl"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n            std"),e("span",{pre:!0,attrs:{class:"token double-colon punctuation"}},[t._v("::")]),t._v("cout "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token string"}},[t._v('"baro_alt_meter: "')]),t._v(" "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" st"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("baro_alt_meter")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" std"),e("span",{pre:!0,attrs:{class:"token double-colon punctuation"}},[t._v("::")]),t._v("endl"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n            std"),e("span",{pre:!0,attrs:{class:"token double-colon punctuation"}},[t._v("::")]),t._v("cout "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token string"}},[t._v('"baro_temp_celcius: "')]),t._v(" "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" st"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("baro_temp_celcius")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" std"),e("span",{pre:!0,attrs:{class:"token double-colon punctuation"}},[t._v("::")]),t._v("endl"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n\n        "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n    "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),e("p",[t._v("To build and run the application on Linux:")]),t._v(" "),e("div",{staticClass:"language-sh extra-class"},[e("pre",{pre:!0,attrs:{class:"language-sh"}},[e("code",[t._v("$ "),e("span",{pre:!0,attrs:{class:"token builtin class-name"}},[t._v("source")]),t._v(" clean_all.bash --ros1_ws_dir "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&")]),t._v("lt"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("path/to/px4_ros_com_ros1/ws"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&")]),t._v("gt"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n")])])]),e("p",[t._v("Now you should see the sensor information being printed out:")]),t._v(" "),e("div",{staticClass:"language-sh extra-class"},[e("pre",{pre:!0,attrs:{class:"language-sh"}},[e("code",[t._v("Sample received, "),e("span",{pre:!0,attrs:{class:"token assign-left variable"}},[t._v("count")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("10119")]),t._v("\nReceived sensor_combined data\n"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("==")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("==")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("==")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("==")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("==")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("==")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("==")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("==")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("==")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("==")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("==")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("==")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("==")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("==")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v("\ngyro_rad: -0.0103228, "),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("0.0140477")]),t._v(", "),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("0.000319406")]),t._v("\ngyro_integral_dt: "),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("0.004")]),t._v("\naccelerometer_timestamp_relative: "),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("0")]),t._v("\naccelerometer_m_s2: -2.82708, -6.34799, -7.41101\naccelerometer_integral_dt: "),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("0.004")]),t._v("\nmagnetometer_timestamp_relative: -10210\nmagnetometer_ga: "),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("0.60171")]),t._v(", "),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("0.0405879")]),t._v(", -0.040995\nbaro_timestamp_relative: -17469\nbaro_alt_meter: "),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("368.647")]),t._v("\nbaro_temp_celcius: "),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("43.93")]),t._v("\n")])])]),e("div",{staticClass:"custom-block note"},[e("p",{staticClass:"custom-block-title"},[t._v("注解")]),t._v(" "),e("p",[t._v("Make sure the "),e("em",[t._v("Client")]),t._v(" is running, if the "),e("em",[t._v("Listener application")]),t._v(" does not print anything.")])]),t._v(" "),e("h2",{attrs:{id:"构建-px4-ros-com-程序包"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#构建-px4-ros-com-程序包"}},[t._v("#")]),t._v(" 构建 "),e("code",[t._v("px4_ros_com")]),t._v(" 程序包")]),t._v(" "),e("p",[t._v("This section is work-in-progress.")]),t._v(" "),e("h2",{attrs:{id:"创建一个-fast-rtps-监听应用"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#创建一个-fast-rtps-监听应用"}},[t._v("#")]),t._v(" 创建一个 Fast RTPS 监听应用")]),t._v(" "),e("h3",{attrs:{id:"ros2-ros-应用"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#ros2-ros-应用"}},[t._v("#")]),t._v(" ROS2/ROS 应用")]),t._v(" "),e("p",[t._v("If the selected UART port is busy, it's possible that the MAVLink application is already being used. If both MAVLink and RTPS connections are required you will have to either move the connection to use another port or using the available protocol splitter for PX4 and companion computers.")]),t._v(" "),e("div",{staticClass:"custom-block tip"},[e("p",{staticClass:"custom-block-title"},[t._v("提示")]),t._v(" "),e("p",[t._v("A quick/temporary fix to allow bridge testing during development is to stop MAVLink from "),e("em",[t._v("NuttShell")]),t._v(":")]),t._v(" "),e("div",{staticClass:"language-sh extra-class"},[e("pre",{pre:!0,attrs:{class:"language-sh"}},[e("code",[e("span",{pre:!0,attrs:{class:"token function"}},[t._v("make")]),t._v(" -f makefile_x64Linux2.6gcc\nbin/*/sensor_combined_PublisherSubscriber subscriber\n")])])])]),t._v(" "),e("h3",{attrs:{id:"分别安装-ros-和-ros2"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#分别安装-ros-和-ros2"}},[t._v("#")]),t._v(" 分别安装 ROS 和 ROS2")]),t._v(" "),e("p",[t._v("The "),e("em",[t._v("Agent")]),t._v(" code is generated using a "),e("em",[t._v("Fast DDS")]),t._v(" tool called "),e("em",[t._v("fastrtpsgen")]),t._v(".")]),t._v(" "),e("p",[t._v("If you haven't installed Fast DDS in the default path then you must specify its installation directory by setting the "),e("code",[t._v("FASTRTPSGEN_DIR")]),t._v(" environment variable before executing "),e("em",[t._v("make")]),t._v(".")]),t._v(" "),e("p",[t._v("On Linux/Mac this is done as shown below:")]),t._v(" "),e("div",{staticClass:"language-sh extra-class"},[e("pre",{pre:!0,attrs:{class:"language-sh"}},[e("code",[t._v("Sample received, "),e("span",{pre:!0,attrs:{class:"token assign-left variable"}},[t._v("count")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("10119")]),t._v("\nReceived sensor_combined data\n"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("==")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("==")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("==")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("==")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("==")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("==")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("==")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("==")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("==")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("==")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("==")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("==")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("==")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("==")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v("\ngyro_rad: -0.0103228, "),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("0.0140477")]),t._v(", "),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("0.000319406")]),t._v("\ngyro_integral_dt: "),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("0.004")]),t._v("\naccelerometer_timestamp_relative: "),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("0")]),t._v("\naccelerometer_m_s2: -2.82708, -6.34799, -7.41101\naccelerometer_integral_dt: "),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("0.004")]),t._v("\nmagnetometer_timestamp_relative: -10210\nmagnetometer_ga: "),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("0.60171")]),t._v(", "),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("0.0405879")]),t._v(", -0.040995\nbaro_timestamp_relative: -17469\nbaro_alt_meter: "),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("368.647")]),t._v("\nbaro_temp_celcius: "),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("43.93")]),t._v("\n")])])]),e("div",{staticClass:"custom-block note"},[e("p",{staticClass:"custom-block-title"},[t._v("注解")]),t._v(" "),e("p",[t._v("This should not be a problem if "),e("RouterLink",{attrs:{to:"/zh/dev_setup/fast-dds-installation.html"}},[t._v("Fast DDS is installed in the default location")]),t._v(".")],1)]),t._v(" "),e("h3",{attrs:{id:"enable-uart-on-a-companion-computer"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#enable-uart-on-a-companion-computer"}},[t._v("#")]),t._v(" Enable UART on a companion computer")]),t._v(" "),e("p",[t._v("For UART transport on a Raspberry Pi or any other companion computer you will have to enable the serial port:")]),t._v(" "),e("ol",[e("li",[e("p",[t._v("Make sure the "),e("code",[t._v("userid")]),t._v(" (default is pi on a Raspberry Pi) is a member of the "),e("code",[t._v("dialout")]),t._v(" group:")]),t._v(" "),e("div",{staticClass:"language-sh extra-class"},[e("pre",{pre:!0,attrs:{class:"language-sh"}},[e("code",[e("span",{pre:!0,attrs:{class:"token function"}},[t._v("groups")]),t._v(" pi\n"),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("sudo")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("usermod")]),t._v(" -a -G dialout pi\n")])])])]),t._v(" "),e("li",[e("p",[t._v("For the Raspberry Pi in particular, you need to stop the GPIO serial console that is using the port:")]),t._v(" "),e("div",{staticClass:"language-sh extra-class"},[e("pre",{pre:!0,attrs:{class:"language-sh"}},[e("code",[e("span",{pre:!0,attrs:{class:"token function"}},[t._v("sudo")]),t._v(" raspi-config\n")])])]),e("p",[t._v("In the menu showed go to "),e("strong",[t._v("Interfacing options > Serial")]),t._v(". Select "),e("strong",[t._v("NO")]),t._v(" for "),e("em",[t._v("Would you like a login shell to be accessible over serial?")]),t._v(". Valid and reboot.")])]),t._v(" "),e("li",[e("p",[t._v("Check UART in kernel:")]),t._v(" "),e("div",{staticClass:"language-sh extra-class"},[e("pre",{pre:!0,attrs:{class:"language-sh"}},[e("code",[e("span",{pre:!0,attrs:{class:"token function"}},[t._v("sudo")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("vi")]),t._v(" /boot/config.txt\n")])])]),e("p",[t._v("And make sure that the "),e("code",[t._v("enable_uart")]),t._v(" value is set to 1:")]),t._v(" "),e("div",{staticClass:"language- extra-class"},[e("pre",{pre:!0,attrs:{class:"language-text"}},[e("code",[t._v(" enable_uart=1\n")])])])])]),t._v(" "),e("h2",{attrs:{id:"创建一个-ros2-监听器"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#创建一个-ros2-监听器"}},[t._v("#")]),t._v(" 创建一个 ROS2 监听器")]),t._v(" "),e("ul",[e("li",[e("RouterLink",{attrs:{to:"/zh/dev_setup/fast-dds-installation.html"}},[t._v("Fast DDS Installation")])],1),t._v(" "),e("li",[e("RouterLink",{attrs:{to:"/zh/middleware/micrortps_manual_code_generation.html"}},[t._v("Manually Generate Client and Agent Code")])],1)])])}),[],!1,null,null,null);s.default=n.exports}}]);