手动生成客户端和代理端代码
本主题演示如何手动生成客户端和代理的代码(而不是编译 PX4 时自动生成的)。
代码是使用 python 脚本生成的:/Tools/generate_microRTPS_bridge.py。
首先禁用桥接代码的自动生成。 First disable automatic generation of bridge code. Set the variable GENERATE_RTPS_BRIDGE
to off in the .cmake file for the target platform: :::
禁用自动桥接代码生成
First disable automatic generation of bridge code. Set the variable GENERATE_RTPS_BRIDGE
to off in the .cmake file for the target platform:
使用 generate_microRTPS_bridge. py
The generate_microRTPS_bridge tool's command syntax is shown below:
:::caution Using with --delete-tree
option erases the content of the CLIENTDIR
and the AGENTDIR
before creating new files and folders. :::
The arguments
--send/-s
and--receive/-r
specify the uORB topics that can be sent/received from PX4. Code will only be generated for specified messages. 将仅为指定的消息生成代码。输出显示在
CLIENTDIR
(默认情况下src/modules/micrortps_bridge/micrortps_client</0 >) 和 <code>AGENTDIR
(默认情况下 `-u src/modules/micrortps_bridge/micrortps_agent</0 >) 中。如果未指定标志 -a` 或 `-c`,则将生成并安装客户端和代理。 - 如果未在默认位置(`-f /path/to/fastrtps/installation/bin`)安装 *Fast rtps*,则可能需要 `-f` 选项。
可以在此处找到网桥的手动生成的代码(默认情况下):
生成代码Code is generated for the Client, Agent, CDR serialization/deserialization of uORB messages, and the definition of the associated RTPS messages (IDL files).
Manually generated code for the bridge can be found here (by default):
客户端: src/modules/micrortps_bridge/micrortps_client/
代理端: src/modules/micrortps_bridge/micrortps_agent/
uORB 序列化代码FastRTSP 使用 IDL 文件来定义 RTPS 消息的结构(在本例中,映射到 uORB 主题的 RTPS 消息)。 FastRTSP uses IDL files to define the structure of RTPS messages (in this case, RTPS messages that map to uORB topics). They are used to generate code for the Agent, and FastRTSP applications that need to publish/subscribe to uORB topics.
RTPS 报文 IDL 文件IDL files are generated from the uORB .msg files (for selected uORB topics) in the generation of the bridge. These can be found in: src/modules/micrortps_bridge/micrortps_agent/idl/
Fast DDS uses IDL files to define the structure of RTPS/DDS messages (in this case, RTPS/DDS messages that map to uORB topics). They are used to generate code for the Agent, and Fast DDS applications that need to publish/subscribe to uORB topics.
代码生成验证The manually generated Client code is built and used in exactly the same way as automatically generated Client code.
Agent directory:
Client directory:
构建并使用代码The manually generated Client code is built and used in exactly the same way as automatically generated Client code.
Specifically, once manually generated, the Client source code is compiled and built into the PX4 Firmware as part of the normal build process. For example, to compile the code and include it in Firmware for NuttX/Pixhawk targets:
The manually generated Agent code is also compiled and used in the same way as the automatically generated code. The only difference is that the manually source code is created in src/modules/micrortps_bridge/micrortps_agent instead of build/BUILDPLATFORM/src/modules/micrortps_bridge/micrortps_agent/.
Last updated