OffCtrlMsgAll Module Documentation¶
Toolbox: RflySim APIs

Introduction¶
One-sentence Description: This module subscribes to and outputs all uORB messages related to Offboard control modes from the PX4 flight controller, providing complete flight controller state and control setpoint information for offline control development on the Simulink side.
This module belongs to the RflySim APIs interface library and serves as a core communication module in the RflySim toolchain for Offboard-mode drone development. It is specifically designed to provide data sources for developing custom offline control algorithms in the Simulink environment. During simulation, this module interacts with the PX4 flight controller and the CopterSim physics engine simulation program, subscribing to five categories of uORB messages related to Offboard control—vehicle_status, offboard_control_mode, trajectory_setpoint, vehicle_attitude_setpoint, and vehicle_rates_setpoint—and integrating all message fields before outputting them via the MsgBus bus to the custom control logic within Simulink.
A typical use case for this module is supporting Offboard control algorithm development. Developers can directly obtain the current state and existing control setpoints of the PX4 flight controller, eliminating the need to configure multiple message subscription modules separately. This simplifies the Simulink model setup process and enables rapid development and validation of custom offline control algorithms based on PX4. When combined with the RflySim3D visualization module, it supports end-to-end closed-loop simulation verification. Specific definitions of each output message field can be found in the PX4 official documentation or in the definition files located in the Firmware\msg directory under the RflySim installation path.
Port Descriptions¶
Input Ports (Inputs)¶
This module has no input ports.
Output Ports (Outputs)¶
| Port Name | Data Type | Dimension | Description |
|---|---|---|---|
MsgBus |
Bus |
- | Outputs all data defined in the uORB messages: vehicle_status, offboard_control_mode, trajectory_setpoint, vehicle_attitude_setpoint, and vehicle_rates_setpoint |
Parameter Configuration (Parameters)¶
The Mask dialog box, opened by double-clicking the module, allows configuration of the following parameters:
| Parameter Name | Type | Default Value | Optional Values/Range | Description |
|---|---|---|---|---|
Sample Time(s) |
double |
0.01 |
>0 |
Sampling time for the module’s output data |
Parameter Setting Description¶
Sample Time(s)¶
This parameter specifies the sampling step size of the module, controlling the frequency at which Offboard-related control messages are output. It can be adjusted according to the control requirements of the simulation task.
Module Characteristics (Block Characteristics)¶
| Characteristic | Value |
|---|---|
| Supported Data Types | double, single |
| Direct Feedthrough | No |
| Sample Time | Discrete |
| Code Generation Support | No |
Data Communication Protocol¶
This module communicates with the PX4 flight controller simulation process via UDP to retrieve uORB topic data. By default, it uses the UDP data port provided by the flight controller to complete message subscription and outputs the integrated uORB message bus data.
Related Modules¶
| Module Name | Description |
|---|---|
VehicleStatusGet |
Parses the message bus output by OffCtrlMsgAll to extract vehicle_status state data |
OffboardModeSet |
Sends Offboard mode switching commands to the flight controller |
SetPointSender |
Sends various control setpoints to the flight controller for use with Offboard control |
UORB_Read |
Reads message data for a single specified uORB topic |
UORB_Write |
Writes message data to a single specified uORB topic |
Usage Example¶
For relevant usage examples, refer to the following path:
Please refer to
Readme.pdfin the above path for complete example descriptions and operational steps.
Notes and Common Issues¶
- Initialization Sequence: This module relies on the PX4 firmware’s uORB message mechanism for data subscription. Before simulation starts, ensure that the RflySim environment has been initialized and the PX4 simulation process has started normally; otherwise, message subscription may fail, resulting in all-zero output data.
- Sample Time Matching: Set the sample time of this module to match that of the Offboard control logic module to avoid control message read delays and abnormal control behavior caused by mismatched sampling frequencies. PX4 Offboard control requires heartbeat messages to be refreshed at least every 500 ms; it is recommended that this module’s sample time be no greater than 0.2 s to ensure data real-time performance.
- Message Output Usage: This module outputs an integrated MsgBus bus signal. To extract individual fields from a specific uORB message, use Simulink’s Bus Selector module. Field definitions can be found in the corresponding message files located in the
Firmware\msgfolder under the RflySim installation directory. - Mode Compatibility Note: This module outputs valid message data only when the PX4 flight controller is in Offboard control mode. If the drone is in another flight mode, some control-related message fields will retain default values. When developing Offboard control logic, first use the
vehicle_statusmessage output by this module to confirm that the flight controller has switched to Offboard mode before executing the control algorithm.
Changelog¶
v4.00(2024-08-07): Initial release. Supports subscription to five uORB messages related to Offboard control:vehicle_status,offboard_control_mode,trajectory_setpoint,vehicle_attitude_setpoint, andvehicle_rates_setpoint, and outputs all defined data within these messages via bus.