uav_flight_control.h
8.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
#ifndef __UAV_FLIGHT_CONTROL_HPP__
#define __UAV_FLIGHT_CONTROL_HPP__
#include <string>
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
UAV_FLIGHTCONTROL_MODE_UNKNOWN = 0,
UAV_FLIGHTCONTROL_MODE_POS_CTL = 1,
UAV_FLIGHTCONTROL_MODE_SPEED_CTL = 2,
}E_UAVFlithtControl_Mode;
typedef enum {
UAV_FLIGHTCONTROL_RC_LOST_ACTION_HOVER = 0, /*!< Aircraft will execute hover cation when rc is lost. */
UAV_FLIGHTCONTROL_RC_LOST_ACTION_LANDING = 1, /*!< Aircraft will execute land cation when rc is lost. */
UAV_FLIGHTCONTROL_RC_LOST_ACTION_GOHOME = 2, /*!< Aircraft will execute go-home cation when rc is lost. */
}E_UAVFlightControl_RCLost_Action;
/*
* @note Attention:Enable emergency-stop-motor function is very dangerous in the air.it will make the aircraft crash!!!
*/
typedef enum {
UAV_FLIGHTCONTROL_ENABLE_EMERGENCY_STOP_MOTOR = 1, /*!< Execute emergency-stop-motor action */
}E_UAVFlightControl_Emergency_Stop_Motor;
typedef struct {
double latitude; /*!< Specifies latitude, unit: rad */
double longitude; /*!< Specifies longitude, unit: rad */
float altitude; /*!< Specifies altitude, unit: m */
}T_UAVFlightControllerRidInfo;
extern T_UAVReturnCode UAV_FlightControl_Init(T_UAVFlightControllerRidInfo ridInfo);
extern void UAV_FlightControl_Deinit(void);
/**
* @brief Set flight control mode.
* @param mode: see reference of E_UAVFlithtControl_Mode.
* @return Execution result.
*/
extern T_UAVReturnCode UAV_FlightControl_SetControlMode(E_UAVFlithtControl_Mode mode);
/**
* @brief Get flight control mode.
* @param mode: see reference of E_UAVFlithtControl_Mode.
* @return Execution result.
*/
extern T_UAVReturnCode UAV_FlightControl_GetControlMode(E_UAVFlithtControl_Mode &mode);
typedef enum {
UAV_HEADING_MODE_NONE = 0, /*!< No heading mode. */
UAV_HEADING_MODE_ALONG = 1, /*!< Along the waypoint line direction. */
UAV_HEADING_MODE_BY_PSDK = 2,/*!< Control the heading by psdk from user. */
}E_HEADING_MODE;
typedef enum {
UAV_OBSTACLE_MODE_NONE = 0, /*!< No obstacle avoidance. */
UAV_OBSTACLE_MODE_LOITER = 1, /*!< Loiter mode. */
UAV_OBSTACLE_MODE_OBS = 2, /*!< Obstacle avoidance mode. */
}E_OBSTACLE_MODE;
typedef struct {
float yaw; /*!< Specifies yaw angle. */
double latitude; /*!< Specifies latitude. */
double longitude; /*!< Specifies longitude. */
double altitude; /*!< Specifies altitude. */
int32_t obstacle_mode; /*!< Specifies obstacle mode, see E_OBSTACLE_MODE. */
}T_UAVFlightControlPos;
/**
* @brief use position to control UAV.
* @param pos: see reference of T_UAVFlightControlPos.
* @return Execution result.
*/
extern T_UAVReturnCode UAV_FlightControl_POSControl(T_UAVFlightControlPos pos);
typedef struct {
float x; /*!< Specifies x coordinate. */
float y; /*!< Specifies y coordinate. */
float z; /*!< Specifies z coordinate. */
float yaw; /*!< Specifies yaw angle. */
int32_t heading_mode; /*!< Specifies heading mode, see E_HEADING_MODE. */
int32_t obstacle_mode; /*!< Specifies obstacle mode, see E_OBSTACLE_MODE. */
}T_UAVFlightControlSpeed;
/**
* @brief use speed to control UAV.
* @param speed: see reference of T_UAVFlightControlSpeed.
* @return Execution result.
*/
extern T_UAVReturnCode UAV_FlightControl_SpeedControl(T_UAVFlightControlSpeed speed);
/**
* @brief Enable/Disable RTK position function.
* @details Enabling RTK means that RTK data will be used instead of GPS during flight.
* @return Execution result.
*/
extern T_UAVReturnCode UAV_FlightControl_SetRtkPositionEnableStatus(bool enable);
/**
* @brief Get RTK enable status.
* @note Enabling RTK means that RTK data will be used during intelligent flight.
* @return Execution result.
*/
extern T_UAVReturnCode UAV_FlightControl_GetRtkPositionEnableStatus(bool &enable);
/**
* @brief Set rc lost action.
* @note It will be valid when rc and osdk is both lost.
* @param rcLostAction: actions when rc is lost.(hover/landing/go home).
* @return Execution result.
*/
extern T_UAVReturnCode UAV_FlightControl_SetRCLostAction(E_UAVFlightControl_RCLost_Action rcLostAction);
/**
* @brief Get rc lost action(hover/landing/gohome).
* @note It will be valid when rc and osdk is both lost.
* @param rcLostAction: see reference of E_UAVFlightControl_RCLost_Action.
* @return Execution result.
*/
extern T_UAVReturnCode UAV_FlightControl_GetRCLostAction(E_UAVFlightControl_RCLost_Action &rcLostAction);
/**
* @brief Turn on motors when the UAV is on the ground.
* @return Execution result.
*/
extern T_UAVReturnCode UAV_FlightControl_TurnOnMotors(void);
/**
* @brief Turn off motors when the UAV is on the ground.
* @return Execution result.
*/
extern T_UAVReturnCode UAV_FlightControl_TurnOffMotors(void);
/**
* @brief Emergency stop motor in any case.
* @note If you want to turn on motor after emergency stopping motor, you need to use the interface to send disable
* command to quit lock-motor status.
* @param cmd: see reference of E_UAVFlightControl_Emergency_Stop_Motor
* @param debugMsg:inject debug message to flight control FW for logging, size limit: 32 bytes
* @return Execution result.
*/
extern T_UAVReturnCode UAV_FlightControl_EmergencyStopMotor(E_UAVFlightControl_Emergency_Stop_Motor command, const char debugMsg[32]);
/**
* @brief Request take off action when the UAV is on the ground.
* @return Execution result.
*/
extern T_UAVReturnCode UAV_FlightControl_StartTakeoff(void);
/**
* @brief Request landing action when the UAV is in the air.
* @return Execution result.
*/
extern T_UAVReturnCode UAV_FlightControl_StartLanding(void);
/**
* @brief Request cancel landing action when the UAV is landing
* @return Execution result.
*/
extern T_UAVReturnCode UAV_FlightControl_CancelLanding(void);
/**
* @brief Force landing in any case.
* @note This api will ignore the smart landing function,.When using this pi, it will landing directly (would not stop
* at 0.7m and wait user's command). Attention:it may make the aircraft crash!!!
* @return Execution result.
*/
extern T_UAVReturnCode UAV_FlightControl_StartForceLanding(void);
typedef struct {
double latitude; /*!< unit: rad */
double longitude; /*!< unit: rad */
} T_UavFlightControllerHomeLocation; // pack(1)
/**
* @brief Set customized GPS(not RTK) home location.
* @note Set customized home location failed reason may as follows:
* 1. The distance between new home location and last home location is larger than MAX_FLY_RADIUS(20km).
* 2. Record initial home location failed after start aircraft.
* @param homeLocation: homeLocation include latitude and longitude
* @return Execution result.
*/
extern T_UAVReturnCode UAV_FlightControl_SetHomeLocationUsingGPSCoordinates(T_UavFlightControllerHomeLocation homeLocation);
/**
* @brief Set home location using current aircraft GPS(not RTK) location.
* @note Set home location failed reasons may as follows:
* 1. Aircraft's gps level can't reach the condition of recording home location.
* 2. Record initial home location failed after start aircraft.
* @return Execution result.
*/
extern T_UAVReturnCode UAV_FlightControl_SetHomeLocationUsingCurrentAircraftLocation(void);
typedef uint16_t E_UavFlightControllerGoHomeAltitude; /*!< Unit:meter, range 20~500 */
/**
* @brief Set go home altitude.
* @note If aircraft's current altitude is higher than the setting value of go home altitude, aircraft will go home
* using current altitude. Otherwise, it will climb to setting of go home altitude ,and then execute go home action.
* Go home altitude setting is 20m ~ 1500m.
* @param altitude: go home altitude, unit: meter
* @return Execution result.
*/
extern T_UAVReturnCode UAV_FlightControl_SetGoHomeAltitude(E_UavFlightControllerGoHomeAltitude altitude);
/**
* @brief Get go home altitude.
* @param altitude: go home altitude, unit: meter
* @return Execution result.
*/
extern T_UAVReturnCode UAV_FlightControl_GetGoHomeAltitude(E_UavFlightControllerGoHomeAltitude *altitude);
/**
* @brief Request go home action when the UAV is in the air
* @return Execution result.
*/
extern T_UAVReturnCode UAV_FlightControl_StartGoHome(void);
/**
* @brief Request cancel go home action when the UAV is going home
* @return Execution result.
*/
extern T_UAVReturnCode UAV_FlightControl_CancelGoHome(void);
typedef struct {
char serialNum[32];
} T_UavFlightControllerGeneralInfo;
/**
* @brief Get general info of the aircraft.
* @param generalInfo: the struct stored the serial num which contains a array of chars var in case the user gives an
* illegal length character pointer
* @return Execution result.
*/
extern T_UAVReturnCode UAV_FlightControl_GetGeneralInfo(T_UavFlightControllerGeneralInfo *generalInfo);
#ifdef __cplusplus
}
#endif
#endif // __UAV_FLIGHT_CONTROL_HPP__