RflySim APIs - Low-Level Control Interface Library
The RflySim APIs library provides a complete set of low-level control interfaces, covering read/write operations for key data such as attitude, velocity, position, acceleration, force/torque, remote controller, and actuators, supporting user-defined controller development and real-machine deployment.
Module List
HIL Control Interfaces
| Module |
Function Description |
| HIL16 Ctrls Norm |
HIL 16-dimensional normalized control interface, outputting normalized actuator control commands |
| HIL16 Ctrls PWM |
HIL 16-dimensional PWM control interface, outputting PWM-format actuator control signals |
Remote Controller Interfaces
| Module |
Function Description |
| Input RC Cali |
Remote controller input calibration module, supporting channel calibration and neutral point setting |
| Input RC Norm |
Normalized remote controller input, converting raw PWM signals to standardized values in the [-1, 1] range |
| RC Over Ctrl |
Remote controller override control, enabling RC signal priority over automatic controllers |
Offboard Control Interfaces
| Module |
Function Description |
| Offboard PVA Ctrl |
Offboard position/velocity/acceleration control, supporting multi-level control of position, velocity, and acceleration |
| Offboard Att Ctrl |
Offboard attitude control, supporting attitude angle and angular rate control |
| Offboard Adv Ctrl |
Offboard advanced control, supporting more complex control modes and hybrid control strategies |
| Off Ctrl Msg All |
Offboard control message aggregation, integrating command outputs from multiple control modes |
State Acquisition Interfaces
| Module |
Function Description |
| Pos Vel Att All |
Full-state acquisition of position/velocity/attitude, outputting the complete motion state of the vehicle |
| Msg2Simulink API |
Message-to-Simulink API, converting MAVLink messages into Simulink-compatible formats |
| Torque Thrust Ctrls |
Torque/thrust control interface, supporting low-level control based on torque and thrust |
Utility Modules
| Module |
Function Description |
| Re PX4 Block |
PX4 module reconfiguration, supporting dynamic reconfiguration of flight controller parameters and module settings |
Usage Scenarios
Custom Controller Development
- Position Controller: Develop custom position, velocity, and acceleration controllers using Offboard PVA Ctrl
- Attitude Controller: Implement custom attitude stabilization and control using Offboard Att Ctrl
- Force-Position Hybrid Control: Achieve low-level force/torque-based control by combining Torque Thrust Ctrls
Real-Machine Deployment
- HIL Simulation Validation: Validate controllers in hardware-in-the-loop simulation using HIL16 Ctrls modules
- Real-Machine Control: Directly control real vehicles using Simulink controllers via Offboard interfaces
- Remote Controller Integration: Enable seamless switching between manual and automatic control using RC-related modules
Data Acquisition and Analysis
- State Monitoring: Acquire the complete motion state of the vehicle using Pos Vel Att All
- Message Parsing: Convert flight controller messages into usable data via Msg2Simulink API
- Real-Time Analysis: Perform real-time analysis of flight controller data and generate control decisions in Simulink
Usage Notes
Offboard Control Notes
- Mode Switching: Ensure the flight controller is in the correct flight mode (typically Position or Hold mode) before entering Offboard mode
- Command Frequency: Offboard control commands must be sent at a sufficiently high frequency (≥50 Hz recommended); otherwise, the flight controller will exit Offboard mode
- Safety Boundaries: Always define reasonable flight boundaries and fault protection mechanisms when using Offboard control
- Coordinate System Convention: Ensure that command outputs from the Simulink controller align with the coordinate system expected by the flight controller (typically NED)
HIL Simulation Notes
- Signal Range: Control signals output by HIL16 Ctrls must conform to the flight controller’s expected normalized or PWM ranges
- Simulation Synchronization: Ensure the Simulink simulation step size matches the flight controller’s control period to avoid timing inconsistencies
- Sensor Models: In HIL simulation, sensor data used by the flight controller originates from the Simulink model; ensure sufficient accuracy of the sensor models
Remote Controller Integration Notes
- Channel Mapping: Ensure RC input channels match the channel functions configured on the flight controller (e.g., throttle, yaw, pitch, roll)
- Loss-of-Signal Protection: Configure appropriate flight controller protection behaviors (e.g., return-to-launch, landing, or hold) when RC signal is lost
- Mode Switching: Properly configure RC channels for flight mode switching to ensure smooth transitions between automatic and manual modes
Note: This document serves as the index for the RflySim APIs library. For detailed usage instructions for each module, please refer to its respective standalone documentation page.