DJI_Flight.h
Go to the documentation of this file.
00001 
00011 #ifndef DJI_FLIGHT_H
00012 #define DJI_FLIGHT_H
00013 
00014 #include "DJI_API.h"
00015 
00016 namespace DJI
00017 {
00018 namespace onboardSDK
00019 {
00020 #pragma pack(1)
00021 
00022 typedef struct FlightData
00023 {
00024   uint8_t flag;
00025   float32_t x;
00026   float32_t y;
00027   float32_t z;
00028   float32_t yaw;
00029 } FlightData;
00030 
00031 #pragma pack()
00032 
00034 class Flight
00035 {
00036   public:
00037   enum TASK
00038   {
00039     TASK_GOHOME = 1,
00040     TASK_TAKEOFF = 4,
00041     TASK_LANDING = 6
00042   };
00043 
00044   enum VerticalLogic
00045   {
00046     VERTICAL_VELOCITY = 0x00,
00047     VERTICAL_POSITION = 0x10,
00048     VERTICAL_THRUST = 0x20,
00049   };
00050 
00051   enum HorizontalLogic
00052   {
00053     HORIZONTAL_ANGLE = 0x00,
00054     HORIZONTAL_VELOCITY = 0x40,
00055     HORIZONTAL_POSITION = 0X80,
00056   };
00057 
00058   enum YawLogic
00059   {
00060     YAW_ANGLE = 0x00,
00061     YAW_RATE = 0x08
00062   };
00063 
00064   enum HorizontalCoordinate
00065   {
00066     HORIZONTAL_GROUND = 0x00,
00067     HORIZONTAL_BODY = 0x02
00068   };
00069 
00071   enum YawCoordinate
00072   {
00073     YAW_GROUND = 0x00,
00074     YAW_BODY = 0X01
00075   };
00077   enum SmoothMode
00078   {
00079     SMOOTH_DISABLE = 0x00,
00080     SMOOTH_ENABLE = 0x01
00081   };
00082 
00083   enum Status
00084   {
00085     STATUS_GROUND_STANDBY = 1,
00086     STATUS_TAKE_OFF = 2,
00087     STATUS_SKY_STANDBY = 3,
00088     STATUS_LANDING = 4,
00089     STATUS_FINISHING_LANDING = 5,
00090   };
00091 
00092 
00093   enum Device
00094   {
00095     DEVICE_RC = 0,
00096     DEVICE_APP = 1,
00097     DEVICE_SDK = 2,
00098   };
00099 
00101   enum Mode
00102   {
00103     ATTI_STOP = 0,
00104     HORIZ_ANG_VERT_VEL_YAW_ANG = 1,
00105     HORIZ_ANG_VERT_VEL_YAW_RATE = 2,
00106     HORIZ_VEL_VERT_VEL_YAW_ANG = 3,
00107     HORIZ_VEL_VERT_VEL_YAW_RATE = 4,
00108     HORIZ_POS_VERT_VEL_YAW_ANG = 5,
00109     HORIZ_POS_VERT_VEL_YAW_RATE = 6,
00110     HORIZ_ANG_VERT_POS_YAW_ANG = 7,
00111     HORIZ_ANG_VERT_POS_YAW_RATE = 8,
00112     HORIZ_VEL_VERT_POS_YAW_ANG = 9,
00113     HORIZ_VEL_VERT_POS_YAW_RATE = 10,
00114     HORIZ_POS_VERT_POS_YAW_ANG = 11,
00115     HORIZ_POS_VERT_POS_YAW_RATE = 12,
00116     HORIZ_ANG_VERT_THR_YAW_ANG = 13,
00117     HORIZ_ANG_VERT_THR_YAW_RATE = 14,
00118     HORIZ_VEL_VERT_THR_YAW_ANG = 15,
00119     HORIZ_VEL_VERT_THR_YAW_RATE = 16,
00120     HORIZ_POS_VERT_THR_YAW_ANG = 17,
00121     HORIZ_POS_VERT_THR_YAW_RATE = 18,
00122     GPS_ATII_CTRL_CL_YAW_RATE = 97,
00123     GPS_ATTI_CTRL_YAW_RATE = 98,
00124     ATTI_CTRL_YAW_RATE = 99,
00125     ATTI_CTRL_STOP = 100,
00126     MODE_NOT_SUPPORTED = 0xFF
00127   };
00128 
00137   public:
00138   Flight(CoreAPI *ControlAPI = 0);
00139 
00140   void task(TASK taskname, CallBack TaskCallback = 0, UserData userData = 0);
00141   unsigned short task(TASK taskname, int timer);
00142   void setArm(bool enable, CallBack ArmCallback = 0, UserData userData = 0);
00143   unsigned short setArm(bool enable, int timer);
00144   void control(uint8_t flag, float32_t x, float32_t y, float32_t z, float32_t yaw); 
00145   void setMovementControl(uint8_t flag, float32_t x, float32_t y, float32_t z, float32_t yaw);
00146   void setFlight(FlightData *data); 
00147 
00148   QuaternionData getQuaternion() const;
00149 
00150   EulerAngle getEulerAngle() const;
00151 
00152   PositionData getPosition() const;
00153   VelocityData getVelocity() const;
00155   CommonData getAcceleration() const;
00156   CommonData getYawRate() const;
00157 
00159   MagnetData getMagnet() const;
00160 
00161   Device getControlDevice() const;
00162   Status getStatus() const;
00163   Mode getControlMode() const;
00164 
00165   Angle getYaw() const;
00166   Angle getRoll() const;
00167   Angle getPitch() const;
00168 
00169   public: 
00170   static void armCallback(CoreAPI *api, Header *protoclHeader, UserData userData = 0);
00171   static void taskCallback(CoreAPI *api, Header *protocolHeader, UserData userData = 0);
00172 
00173   public: 
00174 
00176   static EulerianAngle toEulerianAngle(QuaternionData data);
00177   static EulerAngle toEulerAngle(QuaternionData quaternionData);
00178   static QuaternionData toQuaternion(EulerianAngle eulerAngleData);
00179 
00180   public: 
00181   CoreAPI *getApi() const;
00182   void setApi(CoreAPI *value);
00183 
00184   private:
00185   CoreAPI *api;
00186   TaskData taskData;
00187 
00194 #ifdef USE_SIMULATION
00195   public:
00196   bool isSimulating() const;
00197   void setSimulating(bool value);
00198 
00199   private:
00200   bool simulating;
00201   Vector3dData position;
00202   Vector3dData speed;
00203   EulerAngle AngularSim;
00204 #endif // USE_SIMULATION
00205 };
00206 
00207 } //namespace OnboardSDK
00208 } //namespace DJI
00209 #endif // DJI_FLIGHT_H


dji_sdk_lib
Author(s):
autogenerated on Thu Jun 6 2019 17:55:25