dji_flight_controller.hpp
Go to the documentation of this file.
1 
29 #ifndef DJI_FLIGHT_CONTROLLER_HPP
30 #define DJI_FLIGHT_CONTROLLER_HPP
31 
35 #include "dji_telemetry.hpp"
36 namespace DJI {
37 namespace OSDK {
38 
43  public:
44  FlightController(Vehicle *vehicle);
46 
48  typedef FlightAssistant::RtkEnableData
50  typedef FlightAssistant::AvoidEnable AvoidEnable;
51  typedef FlightAssistant::UpwardsAvoidEnable UpwardsAvoidEnable;
52  typedef FlightAssistant::GoHomeAltitude
55  typedef enum FlightJoystick::HorizontalLogic HorizontalLogic;
56  typedef enum FlightJoystick::VerticalLogic VerticalLogic;
57  typedef enum FlightJoystick::YawLogic YawLogic;
58  typedef enum FlightJoystick::HorizontalCoordinate HorizontalCoordinate;
59  typedef enum FlightJoystick::StableMode StableMode;
60  typedef enum FlightActions::KillSwitch KillSwitch;
61 
62  typedef struct JoystickMode {
63  HorizontalLogic horizontalLogic;
64  VerticalLogic verticalLogic;
65  YawLogic yawLogic;
66  HorizontalCoordinate horizontalCoordinate;
67  StableMode stableMode;
68  } JoystickMode;
69 
79  UserData userData),
80  UserData userData, int timeout, int retryTime);
98  UserData userData),
99  UserData userData, int timeout, int retryTime);
116  ErrorCode::ErrorCodeType setRtkEnableSync(RtkEnabled rtkEnable, int timeout);
117 
129  void setRtkEnableAsync(RtkEnabled rtkEnable,
130  void (*UserCallBack)(ErrorCode::ErrorCodeType retCode,
131  UserData userData),
132  UserData userData);
133 
142  ErrorCode::ErrorCodeType getRtkEnableSync(RtkEnabled &rtkEnable, int timeout);
143 
155  void getRtkEnableAsync(void (*UserCallBack)(ErrorCode::ErrorCodeType retCode,
156  RtkEnabled rtkEnable,
157  UserData userData),
158  UserData userData);
159 
174  int timeout);
175 
193  GoHomeHeight altitude,
194  void (*UserCallBack)(ErrorCode::ErrorCodeType retCode, UserData userData),
195  UserData userData);
196 
205  int timeout);
206 
218  void (*UserCallBack)(ErrorCode::ErrorCodeType retCode,
219  GoHomeHeight altitude, UserData userData),
220  UserData userData);
221 
230  AvoidEnable avoidEnable, int timeout);
231 
243  AvoidEnable avoidEnable,
244  void (*UserCallBack)(ErrorCode::ErrorCodeType retCode, UserData userData),
245  UserData userData);
246 
255  AvoidEnable &avoidEnable, int timeout);
256 
268  void (*UserCallBack)(ErrorCode::ErrorCodeType retCode,
269  AvoidEnable avoidEnable, UserData userData),
270  UserData userData);
271 
272 
281  ErrorCode::ErrorCodeType setUpwardsAvoidanceEnabledSync(UpwardsAvoidEnable upwardsAvoidEnable,
282  int timeout);
283 
295  void setUpwardsAvoidanceEnabledAsync(UpwardsAvoidEnable upwardsAvoidEnable,
296  void (*UserCallBack)(ErrorCode::ErrorCodeType retCode,
297  UserData userData),
298  UserData userData);
299 
308  ErrorCode::ErrorCodeType getUpwardsAvoidanceEnabledSync(UpwardsAvoidEnable &upwardsAvoidEnable,
309  int timeout);
310 
322  void getUpwardsAvoidanceEnabledAsync(void (*UserCallBack)(ErrorCode::ErrorCodeType retCode,
323  UpwardsAvoidEnable upwardsEnable,
324  UserData userData),
325  UserData userData);
326 
327 
339  ErrorCode::ErrorCodeType setHomeLocationSync(HomeLocation homeLocation,
340  int timeout);
341 
357  HomeLocation homeLocation,
358  void (*UserCallBack)(ErrorCode::ErrorCodeType retCode, UserData userData),
359  UserData userData);
360 
372  int timeout);
373 
389  void (*UserCallBack)(ErrorCode::ErrorCodeType retCode, UserData userData),
390  UserData userData);
391 
399 
409  void turnOnMotorsAsync(void (*UserCallBack)(ErrorCode::ErrorCodeType retCode,
410  UserData userData),
411  UserData userData);
412 
420 
430  void turnOffMotorsAsync(void (*UserCallBack)(ErrorCode::ErrorCodeType retCode,
431  UserData userData),
432  UserData userData);
433 
434 
442 
452  void startTakeoffAsync(void (*UserCallBack)(ErrorCode::ErrorCodeType retCode,
453  UserData userData),
454  UserData userData);
455 
463 
473  void startLandingAsync(void (*UserCallBack)(ErrorCode::ErrorCodeType retCode,
474  UserData userData),
475  UserData userData);
476 
484 
494  void cancelLandingAsync(void (*UserCallBack)(ErrorCode::ErrorCodeType retCode,
495  UserData userData),
496  UserData userData);
497 
508 
522  void (*UserCallBack)(ErrorCode::ErrorCodeType retCode, UserData userData),
523  UserData userData);
524 
537 
553  void (*UserCallBack)(ErrorCode::ErrorCodeType retCode, UserData userData),
554  UserData userData);
555 
563 
573  void startGoHomeAsync(void (*UserCallBack)(ErrorCode::ErrorCodeType retCode,
574  UserData userData),
575  UserData userData);
576 
584 
595  void cancelGoHomeAsync(void (*UserCallBack)(ErrorCode::ErrorCodeType retCode,
596  UserData userData),
597  UserData userData);
598 
605  void setJoystickMode(const JoystickMode &joystickMode);
606 
613  void setJoystickCommand(const JoystickCommand &JoystickCommand);
614 
621  void joystickAction();
622 
629  void getJoystickMode(FlightJoystick::ControlMode &joystickMode);
630 
637  void getJoystickCommand(JoystickCommand &joystickCommand);
638 
648  ErrorCode::ErrorCodeType killSwitch(KillSwitch cmd,int wait_timeout,
649  char debugMsg[10]);
650 
656  void emergencyBrakeAction(void);
657 
658  private:
659  FlightAssistant *flightAssistant;
660  FlightActions *flightActions;
661  FlightJoystick *flightJoystick;
662 };
663 } // namespace OSDK
664 } // namespace DJI
665 #endif // DJI_FLIGHT_CONTROLLER_HPP
ErrorCode::ErrorCodeType releaseJoystickCtrlAuthoritySync(int timeout)
Release the control authority of the api (blocking call)
Definition: dji_flight_controller.cpp:92
ErrorCode::ErrorCodeType setUpwardsAvoidanceEnabledSync(UpwardsAvoidEnable upwardsAvoidEnable, int timeout)
Set upwards avoidance enable or disable, blocking calls.
Definition: dji_flight_controller.cpp:233
void * UserData
This is used as the datatype for all data arguments in callbacks.
Definition: dji_type.hpp:75
FlightAssistant::GoHomeAltitude GoHomeHeight
Definition: dji_flight_controller.hpp:53
ErrorCode::ErrorCodeType startConfirmLandingSync(int timeout)
Wrapper function for aircraft confirm landing and avoid ground, blocking calls.
Definition: dji_flight_controller.cpp:456
struct for TOPIC_HOME_POINT_INFO
Definition: dji_telemetry.hpp:342
void joystickAction()
Wrapper function for set joystick action, non-blocking calls.
Definition: dji_flight_controller.cpp:541
void emergencyBrakeAction(void)
Stop the vehicle in horiz velocity, vert velocity, yaw rate mode (body frame)
Definition: dji_flight_controller.cpp:577
void getGoHomeAltitudeAsync(void(*UserCallBack)(ErrorCode::ErrorCodeType retCode, GoHomeHeight altitude, UserData userData), UserData userData)
Get go home altitude, non-blocking calls.
Definition: dji_flight_controller.cpp:174
void startGoHomeAsync(void(*UserCallBack)(ErrorCode::ErrorCodeType retCode, UserData userData), UserData userData)
Wrapper function for go home action, non-blocking calls.
Definition: dji_flight_controller.cpp:486
ErrorCode::ErrorCodeType cancelLandingSync(int timeout)
Wrapper function for cancel aircraft landing, blocking calls.
Definition: dji_flight_controller.cpp:414
ErrorCode::ErrorCodeType setHomeLocationUsingCurrentAircraftLocationSync(int timeout)
Set home location using current aircraft GPS(not RTK) location, blocking calls.
Definition: dji_flight_controller.cpp:308
ErrorCode::ErrorCodeType setCollisionAvoidanceEnabledSync(AvoidEnable avoidEnable, int timeout)
Set collision avoidance enable or disable, blocking calls.
Definition: dji_flight_controller.cpp:188
ErrorCode::ErrorCodeType startGoHomeSync(int timeout)
Wrapper function for go home action, blocking calls.
Definition: dji_flight_controller.cpp:478
ErrorCode::ErrorCodeType setHomeLocationSync(HomeLocation homeLocation, int timeout)
Set customized GPS(not RTK) home location, blocking calls.
Definition: dji_flight_controller.cpp:278
int64_t ErrorCodeType
Unified error type.
Definition: dji_error.hpp:144
ErrorCode::ErrorCodeType getGoHomeAltitudeSync(GoHomeHeight &altitude, int timeout)
Get go home altitude, blocking calls.
Definition: dji_flight_controller.cpp:166
Implementation of flight assistant module.
void setHomeLocationAsync(HomeLocation homeLocation, void(*UserCallBack)(ErrorCode::ErrorCodeType retCode, UserData userData), UserData userData)
Set customized GPS(not RTK) home location, non-blocking calls.
Definition: dji_flight_controller.cpp:289
ErrorCode::ErrorCodeType obtainJoystickCtrlAuthoritySync(int timeout)
Obtain the control authority of the api (blocking call)
Definition: dji_flight_controller.cpp:63
ErrorCode::ErrorCodeType setGoHomeAltitudeSync(GoHomeHeight altitude, int timeout)
Set go home altitude, blocking calls.
Definition: dji_flight_controller.cpp:146
ErrorCode::ErrorCodeType getCollisionAvoidanceEnabledSync(AvoidEnable &avoidEnable, int timeout)
Get collision avoidance enable or disable, blocking calls.
Definition: dji_flight_controller.cpp:210
void getUpwardsAvoidanceEnabledAsync(void(*UserCallBack)(ErrorCode::ErrorCodeType retCode, UpwardsAvoidEnable upwardsEnable, UserData userData), UserData userData)
Get upwards avoidance enable or disable, non-blocking calls.
Definition: dji_flight_controller.cpp:264
ErrorCode::ErrorCodeType cancelGoHomeSync(int timeout)
Wrapper function for stop go home action, blocking calls.
Definition: dji_flight_controller.cpp:499
ErrorCode::ErrorCodeType startForceLandingSync(int timeout)
Wrapper function for aircraft force landing, blocking calls.
Definition: dji_flight_controller.cpp:435
void getRtkEnableAsync(void(*UserCallBack)(ErrorCode::ErrorCodeType retCode, RtkEnabled rtkEnable, UserData userData), UserData userData)
Get RTK enable or disable, non-blocking calls.
Definition: dji_flight_controller.cpp:132
CtrlData used for flight control.
Definition: dji_flight_joystick_module.hpp:156
void turnOnMotorsAsync(void(*UserCallBack)(ErrorCode::ErrorCodeType retCode, UserData userData), UserData userData)
Wrapper function for turn on motors, non-blocking calls.
Definition: dji_flight_controller.cpp:338
ErrorCode::ErrorCodeType startTakeoffSync(int timeout)
Wrapper function for aircraft takeoff, blocking calls.
Definition: dji_flight_controller.cpp:372
ErrorCode::ErrorCodeType turnOffMotorsSync(int timeout)
Wrapper function for turn off motors, blocking calls.
Definition: dji_flight_controller.cpp:351
void getCollisionAvoidanceEnabledAsync(void(*UserCallBack)(ErrorCode::ErrorCodeType retCode, AvoidEnable avoidEnable, UserData userData), UserData userData)
Get collision avoidance enable or disable, non-blocking calls.
Definition: dji_flight_controller.cpp:219
void cancelLandingAsync(void(*UserCallBack)(ErrorCode::ErrorCodeType retCode, UserData userData), UserData userData)
Wrapper function for cancel aircraft landing, non-blocking calls.
Definition: dji_flight_controller.cpp:422
void setGoHomeAltitudeAsync(GoHomeHeight altitude, void(*UserCallBack)(ErrorCode::ErrorCodeType retCode, UserData userData), UserData userData)
Set go home altitude, non-blocking calls.
Definition: dji_flight_controller.cpp:154
void releaseJoystickCtrlAuthorityAsync(void(*userCB)(ErrorCode::ErrorCodeType, UserData userData), UserData userData, int timeout, int retryTime)
Release the control authority of the api (non-blocking call)
Definition: dji_flight_controller.cpp:75
ErrorCode::ErrorCodeType turnOnMotorsSync(int timeout)
Wrapper function for turn on motors, blocking calls.
Definition: dji_flight_controller.cpp:330
void startForceLandingAsync(void(*UserCallBack)(ErrorCode::ErrorCodeType retCode, UserData userData), UserData userData)
Wrapper function for aircraft force landing, non-blocking calls.
Definition: dji_flight_controller.cpp:443
ErrorCode::ErrorCodeType getUpwardsAvoidanceEnabledSync(UpwardsAvoidEnable &upwardsAvoidEnable, int timeout)
Get upwards avoidance enable or disable, blocking calls.
Definition: dji_flight_controller.cpp:255
void setCollisionAvoidanceEnabledAsync(AvoidEnable avoidEnable, void(*UserCallBack)(ErrorCode::ErrorCodeType retCode, UserData userData), UserData userData)
Set collision avoidance enable or disable, non-blocking calls.
Definition: dji_flight_controller.cpp:197
void getJoystickCommand(JoystickCommand &joystickCommand)
Wrapper function for get joystick command, non-blocking calls.
Definition: dji_flight_controller.cpp:549
Implementation of flight actions module.
void startLandingAsync(void(*UserCallBack)(ErrorCode::ErrorCodeType retCode, UserData userData), UserData userData)
Wrapper function for aircraft landing, non-blocking calls.
Definition: dji_flight_controller.cpp:401
void setHomeLocationUsingCurrentAircraftLocationAsync(void(*UserCallBack)(ErrorCode::ErrorCodeType retCode, UserData userData), UserData userData)
Set home location using current aircraft GPS(not RTK) location, non-blocking calls.
Definition: dji_flight_controller.cpp:317
void getJoystickMode(FlightJoystick::ControlMode &joystickMode)
Wrapper function for get joystick mode, non-blocking calls.
Definition: dji_flight_controller.cpp:557
void startConfirmLandingAsync(void(*UserCallBack)(ErrorCode::ErrorCodeType retCode, UserData userData), UserData userData)
Wrapper function for aircraft confirm landing and avoid ground, non-blocking calls.
Definition: dji_flight_controller.cpp:465
void cancelGoHomeAsync(void(*UserCallBack)(ErrorCode::ErrorCodeType retCode, UserData userData), UserData userData)
Wrapper function for stop go home action, non-blocking calls.
Definition: dji_flight_controller.cpp:507
void turnOffMotorsAsync(void(*UserCallBack)(ErrorCode::ErrorCodeType retCode, UserData userData), UserData userData)
Wrapper function for turn off motors, non-blocking calls.
Definition: dji_flight_controller.cpp:359
ErrorCode::ErrorCodeType setRtkEnableSync(RtkEnabled rtkEnable, int timeout)
Set RTK enable or disable, blocking calls.
Definition: dji_flight_controller.cpp:104
Flight controller API: set or get parameter, execute flight actions.
Definition: dji_flight_controller.hpp:42
Enumeration of all telemetry data types, structures and maps.
ErrorCode::ErrorCodeType killSwitch(KillSwitch cmd, int wait_timeout, char debugMsg[10])
Turn on or off the kill switch.
Definition: dji_flight_controller.cpp:566
void setUpwardsAvoidanceEnabledAsync(UpwardsAvoidEnable upwardsAvoidEnable, void(*UserCallBack)(ErrorCode::ErrorCodeType retCode, UserData userData), UserData userData)
Set upwards avoidance enable or disable, non-blocking calls.
Definition: dji_flight_controller.cpp:242
void obtainJoystickCtrlAuthorityAsync(void(*userCB)(ErrorCode::ErrorCodeType, UserData userData), UserData userData, int timeout, int retryTime)
Obtain the control authority of the api (non-blocking call)
Definition: dji_flight_controller.cpp:46
void setJoystickCommand(const JoystickCommand &JoystickCommand)
Wrapper function for set joystick command, non-blocking calls.
Definition: dji_flight_controller.cpp:532
Definition: dji_ack.cpp:38
ErrorCode::ErrorCodeType getRtkEnableSync(RtkEnabled &rtkEnable, int timeout)
Get rtk enable or disable, blocking calls.
Definition: dji_flight_controller.cpp:124
void setRtkEnableAsync(RtkEnabled rtkEnable, void(*UserCallBack)(ErrorCode::ErrorCodeType retCode, UserData userData), UserData userData)
Set RTK enable or disable, non-blocking calls.
Definition: dji_flight_controller.cpp:112
void startTakeoffAsync(void(*UserCallBack)(ErrorCode::ErrorCodeType retCode, UserData userData), UserData userData)
Wrapper function for aircraft takeoff, non-blocking calls.
Definition: dji_flight_controller.cpp:380
ErrorCode::ErrorCodeType startLandingSync(int timeout)
Wrapper function for aircraft landing, blocking calls.
Definition: dji_flight_controller.cpp:393
FlightAssistant::RtkEnableData RtkEnabled
Definition: dji_flight_controller.hpp:49
void setJoystickMode(const JoystickMode &joystickMode)
Wrapper function for set joystick mode, non-blocking calls.
Definition: dji_flight_controller.cpp:519
Implementation of flight actions module.