Flight Control
Overview
By using the PSDK's aircraft flight control functionality, you can set and retrieve various basic parameters of the aircraft and control the aircraft to perform fundamental flight actions.
Basic Concepts
Aircraft Basic Information
PSDK provides interfaces for setting the basic parameters of the aircraft. Developers can set and retrieve these parameters to achieve precise control over the aircraft:
- Set the return-to-home point and return altitude of the aircraft.
- Set the fail-safe behavior.
Applications with information management functionality allow users to easily retrieve basic parameter information of the aircraft:
- Retrieve the aircraft's return-to-home point and return altitude.
Basic Aircraft Flight Actions
The basic aircraft flight actions mainly include aircraft takeoff, landing, and return-to-home. Developers can use the interfaces provided by PSDK to control the aircraft to perform the specified flight actions based on actual control needs.
Function Type | Basic Function | Function Description |
---|---|---|
Takeoff and Landing | Automatic Takeoff | When this function is used, the aircraft will automatically take off |
Automatic Landing | When this function is used, the aircraft will automatically land | |
Cancel Automatic Landing | When this function is used, the aircraft will stop landing during descent and hover in the air | |
Forced Landing | The aircraft will land regardless of the landing surface status (landing speed will be faster) | |
Aircraft Return to Home | Return to Home | When this function is used, the aircraft will automatically return to home |
Cancel Return to Home | When this function is used, the aircraft will hover in the air |
Note
- Different models of aircraft may have different heights when performing takeoff, landing, and return-to-home actions. Please refer to the user manual for the selected aircraft model for more details.
- After unlocking the aircraft, if no takeoff command is received, the aircraft will automatically lock, and the propellers will stop spinning. If unlocking the aircraft fails, please refer to the error code to identify the cause of the failure.
Using Flight Control Functions
To use the aircraft flight control functions, you must first initialize the flight control module, and then set the aircraft's basic parameters.
Note:
- When using PSDK to control the aircraft fully independent of the remote controller, it is necessary to subscribe to key data from the aircraft and strictly check whether the aircraft's current state allows flight control. Always verify critical flight parameters, such as battery level, return-to-home point, fail-safe behavior, RTK switch, and obstacle avoidance switch. Additionally, it is important to comply with local unmanned aircraft regulations. For example, in the US, RID information must be reported, otherwise the aircraft will be restricted from flight. Third-party developers are responsible for ensuring the accuracy of RID information. During the flight mission, real-time monitoring of the aircraft's status and alarm information is essential to assist remote pilots or programs in decision-making. For more details, refer to the Information Management and HMS Functions sections.
1. Initialize Flight Control Module
Before using the relevant flight control function interfaces, you must first call the UAV_FlightControl_Init
interface to initialize the flight control module.
returnCode = UAV_FlightControl_Init(ridInfo);
if (returnCode != true) {
LOG_ERROR("Init flight Control sample failed,error code:0x%08llX", returnCode);
return returnCode;
}
2. Get and Set Aircraft Parameters
Before controlling the aircraft for autonomous flight, it is necessary to check and set the relevant parameters of the aircraft. The flight control module provides a series of Set and Get interfaces, which allow you to retrieve and configure the aircraft's parameters, with changes taking effect in real-time. An example is the fail-safe behavior.
iRet =UAV_FlightControl_SetRCLostAction(UAV_FLIGHTCONTROL_RC_LOST_ACTION_GOHOME);
CHECK("set rc lost action", iRet);
E_FLIGHTCONTROL_LCLOST_ACTION action;
iRet =UAV_FlightControl_GetRCLostAction(&action);
CHECK("get rc lost action", iRet);
3. Control Aircraft to Perform Basic Flight Actions
Developers can use the interfaces provided by PSDK to control the aircraft to perform specific flight actions based on actual control requirements. To ensure flight control safety, it is recommended to use Data Subscription to subscribe to relevant aircraft parameters for closed-loop monitoring and control. This ensures that the flight actions are executed correctly and that the aircraft is operating within safe parameters.
T_UAVReturnCode uavStat;
//! Start takeoff
uavStat = UAV_FlightControl_StartTakeoff();
if (uavStat != true) {
USER_LOG_ERROR("Request to take off failed, error code: 0x%08X", uavStat);
return false;
}