real_data_decoder Module Documentation¶
Toolbox: RflySim Swarm

Introduction¶
One-sentence description: Decodes UAV telemetry data transmitted via UDP packets from the RflyUdpMavlink module and outputs various UAV states and telemetry information through Simulink buses.
This module serves as the core component for decoding flight controller telemetry data within the RflySim Swarm cluster toolchain, primarily used in conjunction with the RflyUdpMavlink module for data processing. It receives raw MAVLink-formatted data output by the RflyUdpMavlink module, decodes it, and outputs various information in the form of Simulink buses. When extracting data, MATLAB automatically prompts available data items within the bus, facilitating rapid access to required information.
The module supports decoding UAV data generated by real PX4 flight controllers and the CopterSim simulation environment. Typical applications include swarm UAV simulation, real UAV status monitoring, and swarm algorithm development and validation. It outputs diverse telemetry data—including position, attitude, velocity, flight mode, battery status, positioning status, and RC input status—from multiple UAVs for use by Simulink user algorithms. When connected to the RflySim3D visualization module, it enables real-time 3D visualization of UAV swarm status.
Port Descriptions¶
Input Ports (Inputs)¶
| Port Name | Data Type | Dimension | Description |
|---|---|---|---|
Input |
uint8 |
N×1 |
Raw UDP datagrams transmitted by the RflyUdpMavlink module [To be confirmed] |
Output Ports (Outputs)¶
| Port Name | Data Type | Dimension | Description |
|---|---|---|---|
VehicleStateBus |
Bus |
Non-standard | Outputs various flight vehicle state information via bus; the bus includes: global position, attitude angles, attitude quaternion, local position, ground speed, manual/automatic RC input, flight controller status, positioning status, flight mode, battery level, key button status, and ground station heartbeat information [To be confirmed] |
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 |
|---|---|---|---|---|
CopterID |
int |
1 |
1~255 |
ID of the UAV whose state data needs to be decoded |
Parameter Setting Description¶
CopterID¶
Specifies the UAV ID whose state information is to be decoded. In multi-UAV cluster network communication scenarios, only the flight state data of the UAV with the specified ID will be output.
Module Characteristics (Block Characteristics)¶
| Characteristic | Value |
|---|---|
| Supported Data Types | double, single |
| Direct Feedthrough | Yes |
| Sample Time | Inherited |
| Code Generation Support | No |
Data Communication Protocol¶
This module does not involve network communication; it only decodes UDP data already received from the RflyUdpMavlink module.
Related Modules¶
| Module Name | Description |
|---|---|
RflyUdpMavlink |
Receives real flight data in MAVLink format via UDP and outputs raw data to this module for decoding |
real_data_encoder |
Encodes simulated UAV state data, suitable for sending simulation data to real flight controllers |
OffboardControlDecode |
Decodes offboard control commands sent by the ground station, used for swarm cluster simulation control |
VehicleStatusBusCombine |
Integrates state bus data from multiple UAVs for cluster simulation data management |
Notes and Common Issues¶
- Initialization Order: This module must be used together with the RflyUdpMavlink module. Prior to simulation startup, ensure that the RflyUdpMavlink module has completed UDP communication port initialization; otherwise, decoding input data will be empty, resulting in all-zero outputs.
- Sample Time Matching: The update frequency of state data output by this module’s decoding depends on the input data reception frequency. Set the sample time of this module to match that of the RflyUdpMavlink module to avoid issues such as duplicate data output or delayed state updates.
- Bus Data Extraction: When using Bus To Element to extract specific state data from the bus, if the bus type prompt indicates a mismatch, right-click the module and select “Update Bus” to refresh the bus definition and synchronize the latest data field list.
- Real-World Data Compatibility: When decoding telemetry data returned by real flight controllers, ensure the MAVLink datagram IDs from the real flight controller match the predefined decoding rules of this module; otherwise, critical states (e.g., flight mode, positioning status) may be decoded incorrectly.
- Multi-UAV Cluster Scenarios: In multi-UAV cluster simulations, each UAV requires its own dedicated real_data_decoder module, connected individually to the corresponding RflyUdpMavlink output. Multiple UAVs must not share the same decoding module.
Changelog¶
v4.0.0(2023-06-15): Initial release. Implemented real_data_decoder decoding functionality, supporting decoding of flight vehicle state data transmitted by RflyUdpMavlink and outputting via bus, covering various information such as position, attitude, velocity, flight controller status, and telemetry data.