dji_flight_joystick_module.hpp
Go to the documentation of this file.
1 
28 #ifndef DJI_FLIGHT_JOYSTICK_MODULE_HPP
29 #define DJI_FLIGHT_JOYSTICK_MODULE_HPP
30 
31 #include "dji_vehicle_callback.hpp"
32 namespace DJI {
33 namespace OSDK {
34 class Vehicle;
35 class FlightLink;
36 class FlightJoystick {
37  public:
38 
39  enum class JoystickCtrlAuthorityCommand {
40  RELEASE_AUTHORITY = 0,
41  OBTAIN_AUTHORITY = 1,
42  };
54  enum HorizontalLogic {
61  HORIZONTAL_ANGLE = 0,
68  HORIZONTAL_VELOCITY = 1,
74  HORIZONTAL_POSITION = 2,
80  HORIZONTAL_ANGULAR_RATE = 3
81  };
82 
90  enum VerticalLogic {
96  VERTICAL_VELOCITY = 0,
101  VERTICAL_POSITION = 1,
106  VERTICAL_THRUST = 2,
107  };
108 
111  enum YawLogic {
117  YAW_ANGLE = 0x00,
123  YAW_RATE = 1
124  };
125 
128  enum HorizontalCoordinate {
130  HORIZONTAL_GROUND = 0,
132  HORIZONTAL_BODY = 1
133  };
134 
147  enum StableMode {
148  STABLE_DISABLE = 0,
149  STABLE_ENABLE = 1
150  };
151 #pragma pack(1)
152 
156  typedef struct ControlCommand {
157  float32_t x;
159  float32_t y;
161  float32_t z;
162  float32_t yaw;
163  } ControlCommand;// pack(1)
164 
165  typedef struct ControlMode {
166  uint8_t stableMode : 1;
167  uint8_t horizFrame : 2;
168  uint8_t yawMode : 1;
169  uint8_t vertiMode : 2;
170  uint8_t horizMode : 2;
171  } ControlMode;// pack(1)
172 
173  typedef struct CtrlData {
174  ControlMode controlMode;
175  ControlCommand controlCommand;
176  } CtrlData; // pack(1)
177 
182  typedef struct AdvancedCtrlData {
183  ControlMode controlMode;
184  uint8_t advFlag;
185  ControlCommand controlCommand;
186  float32_t xFeedforward;
187  float32_t yFeedforward;
188  } AdvancedCtrlData; // pack(1)
189 
190  typedef struct KillSwitchData {
191  uint8_t high_version;
192  uint8_t low_version;
193  uint8_t debug_description[10];
195  uint8_t cmd : 2;
197  uint8_t reserved : 6;
198  } KillSwitchData; // pack(1)
199 
200  typedef struct CommonAck {
201  uint8_t retCode;
202  } CommonAck; // pack(1)
203 #pragma pack()
204 
205  public:
206  FlightJoystick(Vehicle *vehicle);
207  ~FlightJoystick();
208 
209 /* JoystickCtrlAuthority manage */
210  void obtainJoystickCtrlAuthorityAsync(void (*userCB)(ErrorCode::ErrorCodeType,
211  UserData userData),
212  UserData userData, int timeout, int retryTime);
213  ErrorCode::ErrorCodeType obtainJoystickCtrlAuthoritySync(int timeout);
214  void releaseJoystickCtrlAuthorityAsync(void (*userCB)(ErrorCode::ErrorCodeType,
215  UserData userData),
216  UserData userData, int timeout, int retryTime);
217  ErrorCode::ErrorCodeType releaseJoystickCtrlAuthoritySync(int timeout);
218 
219  void setHorizontalLogic(HorizontalLogic horizontalLogic);
220  void setVerticalLogic(VerticalLogic verticalLogic);
221  void setYawLogic(YawLogic yawLogic);
222  void setHorizontalCoordinate(HorizontalCoordinate horizontalCoordinate);
223  void setStableMode(StableMode stableMode);
224 
225  void setControlCommand(const ControlCommand &controlCommand);
226  void joystickAction();
227 
228  void getControlCommand(ControlCommand &controlCommand);
229  void getControlMode(ControlMode &controlCommand);
230 
231  private:
232  CtrlData ctrlData;
233  FlightLink *flightLink;
234 };
235 }
236 }
237 
238 #endif // DJI_FLIGHT_JOYSTICK_MODULE_HPP
void * UserData
This is used as the datatype for all data arguments in callbacks.
Definition: dji_type.hpp:75
int64_t ErrorCodeType
Unified error type.
Definition: dji_error.hpp:144
float32_t x
Definition: dji_flight_joystick_module.hpp:157
Type definition for new Vehicle-style callbacks.
CtrlData used for flight control.
Definition: dji_flight_joystick_module.hpp:156
float32_t y
Definition: dji_flight_joystick_module.hpp:159
float32_t z
Definition: dji_flight_joystick_module.hpp:161
AdvancedCtrlData.
Definition: dji_flight_joystick_module.hpp:182
Definition: dji_ack.cpp:38
float32_t yaw
Definition: dji_flight_joystick_module.hpp:162