Manually Generate Client/Agent
This topic shows how to manually generate the code for the client and the agent (instead of automatically generating it when the PX4 firmware is compiled).
The code is generated using the python script: /Tools/generate_microRTPS_bridge.py.
This method should only be used for debugging purposes when creating new messages or if you just want to consume the generated code outside of the PX4 domain. Otherwise please use the normal method explained in PX4-Fast RTPS(DDS) Bridge, which uses the PX4-Autopilot build system.
Disable automatic bridge code generation
First disable automatic generation of bridge code. Set the variable GENERATE_RTPS_BRIDGE
to off in the .cmake file for the target platform:
Using 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.The output appears in
CLIENTDIR
(-o src/modules/micrortps_bridge/micrortps_client
, by default) and in theAGENTDIR
(-u src/modules/micrortps_bridge/micrortps_agent
, by default).If no flag
-a
or-c
is specified, both the client and the agent will be generated and installed.The
-f
option may be needed if Fast DDS was not installed in the default location (-f /path/to/fastdds/installation/bin
).
The example below shows how you can generate bridge code to publish/subscribe just the sensor_baro
single uORB topic.
Generated code
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):
Client: src/modules/micrortps_bridge/micrortps_client/
Agent: src/modules/micrortps_bridge/micrortps_agent/
uORB serialization code
Serialization functions are generated for all the uORB topics as part of the normal PX4 compilation process (and also for manual generation). For example, the following functions would be generated for the sensor_combined.msg:
RTPS message IDL files
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.
IDL files are compiled to C++ by the fastrtpsgen tool.
Verify code generation
You can verify successful code generation by checking that the output directories match the listing shown below (On Linux, the tree
command can be used for listing the file structure).
Agent directory:
Client directory:
Build and use the code
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:
You must first disable automatic bridge code generation so that the toolchain uses the manually generated source code (and does not attempt to regenerate it).
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