dji_vehicle.hpp
Go to the documentation of this file.
1 
30 #ifndef OSDK_CORE_INC_DJI_VEHICLE_H_
31 #define OSDK_CORE_INC_DJI_VEHICLE_H_
32 
33 #include <stdio.h>
34 #include <cstdint>
35 #include "dji_status.hpp"
36 #include "dji_ack.hpp"
37 #include "dji_type.hpp"
38 #include "dji_vehicle_callback.hpp"
39 #include "dji_version.hpp"
40 #include "dji_legacy_linker.hpp"
41 #include "dji_log.hpp"
42 #include "dji_broadcast.hpp"
43 #include "dji_gimbal.hpp"
44 #include "dji_camera.hpp"
45 #include "dji_control.hpp"
46 #include "dji_subscription.hpp"
47 #include "dji_mobile_device.hpp"
48 #include "dji_payload_device.hpp"
49 #include "dji_hardware_sync.hpp"
50 #include "dji_mfio.hpp"
51 #include "dji_mission_manager.hpp"
52 #include "dji_camera_manager.hpp"
53 #include "dji_gimbal_manager.hpp"
55 #include "dji_psdk_manager.hpp"
56 #include "dji_battery.hpp"
57 #include "dji_waypoint_v2.hpp"
58 #ifdef ADVANCED_SENSING
59 #include "dji_advanced_sensing.hpp"
60 #endif
61 #if defined(__linux__)
62 #include "dji_hms.hpp"
63 #include "dji_mop_server.hpp"
64 #endif
65 
66 namespace DJI
67 {
68 namespace OSDK
69 {
78 //forward declaration
79 class Firewall;
80 class Linker;
81 
82 class Vehicle
83 {
84 public:
85 #pragma pack(1)
86  typedef struct ActivateData
87  {
88  uint32_t ID;
89  uint32_t reserved;
90  uint32_t version;
91  uint8_t iosID[32];
92  char* encKey;
93  } ActivateData; // pack(1)
94 #pragma pack()
95 
96 public:
97  Vehicle(Linker* linker);
98  ~Vehicle();
99 
100  Linker* linker;
101  LegacyLinker* legacyLinker;
102  DataSubscription* subscribe;
103  DataBroadcast* broadcast;
104  Control* control;
105  Camera* camera;
106  Gimbal* gimbal;
107  MFIO* mfio;
108  MobileDevice* mobileDevice;
109  MissionManager* missionManager;
110 #if defined(__linux__)
111  WaypointV2MissionOperator* waypointV2Mission;
112 #endif
113  HardwareSync* hardSync;
114  // Supported only on Matrice 100
115  PayloadDevice* payloadDevice;
116  CameraManager* cameraManager;
117  FlightController* flightController;
118  PSDKManager* psdkManager;
119  GimbalManager* gimbalManager;
120 
121 #if defined(__linux__)
122  DJIHMS* djiHms;
123  MopServer* mopServer;
124 #endif
125 
126 #ifdef ADVANCED_SENSING
127  AdvancedSensing* advancedSensing;
128 #endif
129 
130  DJIBattery* djiBattery;
131  int functionalSetUp();
133 
143  void activate(ActivateData* data, VehicleCallBack callback = 0,
144  UserData userData = 0);
145 
162  ACK::ErrorCode activate(ActivateData* data, uint32_t timeoutMs);
163 
172  bool setUSBFlightOn(bool en);
173 
183  bool setSimulationOn(bool en, float64_t latitude, float64_t longitude);
184 
189  static void activateCallback(Vehicle* vehiclePtr, RecvContainer recvFrame,
190  UserData userData = 0);
195  static void getDroneVersionCallback(Vehicle* vehiclePtr,
196  RecvContainer recvFrame,
197  UserData userData = 0);
211  ACK::DroneVersion getDroneVersion(uint32_t timeoutMs);
213 
220  void getDroneVersion(VehicleCallBack callback = 0, UserData userData = 0);
221 
223 
229  ActivateData getAccountData() const;
230 
236  void setAccountData(const ActivateData& value);
237 
243  void setVersion(const Version::FirmWare& value);
244 
245 private:
246  static HeartBeatPack heartBeatPack;
247  static uint8_t fcLostConnectCount;
248  const static uint8_t kMaxFCLostConnectCount = 5;
249  const static uint8_t kOSDKSendId;
250  const static uint32_t kHeartBeatPackSendTimeInterval;
251 
252 public:
253  Version::FirmWare getFwVersion() const;
254  char* getHwVersion() const;
255  char* getHwSerialNum() const;
256  bool isLegacyM600();
257  bool isM100();
258  bool isM210V2();
259  bool isM300();
260 
261 private:
262  Version::VersionData versionData;
263  ActivateData accountData;
264 
265 private:
266  bool is_activated = false;
267  bool encrypt = false;
268 
269 public:
270 
271  // User space ACK types
272  ACK::ErrorCode ackErrorCode;
273  ACK::DroneVersion droneVersionACK;
274 
275 public:
276  bool init();
277 
278  bool initVersion();
279 
280 public:
281  static bool parseDroneVersionInfo(Version::VersionData& versionData,
282  uint8_t* ackPtr);
283 
284 private:
285  const int wait_timeout = 1000;
286  const int GIMBAL_MOUNTED = 1;
287  static const uint8_t NUM_CMD_SET = 10;
288  CMD_SETSupportMatrix cmd_setSupportMatrix[NUM_CMD_SET];
289 
290 public:
291  void setEncryption(bool encryptSetting);
292  bool getEncryption();
293  bool getActivationStatus();
294 
299  bool initLegacyLinker();
300  bool initSubscriber();
301  bool initBroadcast();
302  bool initControl();
303  bool initCamera();
304  bool initGimbal();
305  bool initMFIO();
306  bool initMobileDevice();
307  bool initPayloadDevice();
308  bool initMissionManager();
309  bool initWaypointV2Mission();
310  bool initHardSync();
311  bool initCameraManager();
312  bool initFlightController();
313  bool initPSDKManager();
314  bool initGimbalManager();
315 #if defined(__linux__)
316  bool initDJIHms();
317  bool initMopServer();
318 #endif
319  bool initOSDKHeartBeatThread();
320 #ifdef ADVANCED_SENSING
321  bool initAdvancedSensing();
322 #endif
323  bool initDJIBattery();
324 
325 #ifdef ADVANCED_SENSING
326 
331  void processAdvancedSensingImgs(RecvContainer* receivedFrame);
332 
333  bool advSensingErrorPrintOnce;
334 #endif
335 private:
336  Firewall *firewall;
337  bool initFirewall();
338 
339  void setActivationStatus(bool is_activated);
340  void initCMD_SetSupportMatrix();
341  bool isCmdSetSupported(const uint8_t cmdSet);
342 
343  void sendBuriedDataPkgToFC(void);
344 
345  static void fcLostConnectCallBack(void);
346  static uint8_t sendHeartbeatToFCFunc(Linker * linker);
347  T_OsdkTaskHandle sendHeartbeatToFCHandle;
348  static void *sendHeartbeatToFCTask(void *arg);
349 };
350 }
351 }
352 #endif /* OSDK_CORE_INC_DJI_VEHICLE_H_ */
void * UserData
This is used as the datatype for all data arguments in callbacks.
Definition: dji_type.hpp:75
Gimbal API for OSDK library.
Implementation of the mop client.
The manager of camera module.
Definition: dji_camera_manager.hpp:42
Definition: dji_waypoint_v2.hpp:52
APIs for controlling Hardware Sync.
Definition: dji_hardware_sync.hpp:57
DJI health manager system of drone.
Definition: dji_hms.hpp:97
Define CMD_SET support matrix.
Definition: dji_version.hpp:112
Broadcast Telemetry API for DJI onboardSDK library.
This struct is returned from all blocking calls, except certain mission calls that have explicit type...
Definition: dji_ack.hpp:146
Type definition for new Vehicle-style callbacks.
Flight control API: high-level actions and low-level control modes.
Definition: dji_control.hpp:48
Control API for DJI OSDK library.
MFIO API for DJI OSDK library.
APIs for Multi-Function Input-Output functionality.
Definition: dji_mfio.hpp:56
Hardware Sync API for DJI OSDK.
void(* VehicleCallBack)(Vehicle *vehicle, RecvContainer recvFrame, UserData userData)
Function prototype for all callback functions used in the OSDK.
Definition: dji_vehicle_callback.hpp:76
Legacy adapting in linker for OSDK 3.9.
Mission-Manager API for DJI OSDK library.
Definition: dji_advanced_sensing.hpp:69
The manager of gimbal module.
Definition: dji_gimbal_manager.hpp:39
MissionManager class for chaining/managing missions.
Definition: dji_mission_manager.hpp:62
Telemetry API through asynchronous "Subscribe"-style messages.
Definition: dji_subscription.hpp:180
Received info.
Definition: dji_vehicle_callback.hpp:59
Implementation of DJI Mobile Device Abstraction.
Telemetry API through asynchronous "Broadcast"-style messages.
Definition: dji_broadcast.hpp:52
Flight controller API: set or get parameter, execute flight actions.
Definition: dji_flight_controller.hpp:42
Implementation of the manager for gimbal module.
Data type and Data Structure definitions for use throughout DJI OSDK.
This struct is returned from the DJI::OSDK::Vehicle::getDroneVersion blocking API.
Definition: dji_ack.hpp:245
APIs for Mobile-Onboard SDK Communication.
Definition: dji_mobile_device.hpp:34
APIs for Payload-Onboard SDK Communication.
Definition: dji_payload_device.hpp:35
HMS(Health Management System) API for DJI OSDK @Details Provide API to subscribe Flight's Health Stat...
Implementation of GPS Waypoint Missions for DJI OSDK.
The Gimbal class for controlling gimbal-related functions.
Definition: dji_gimbal.hpp:46
Definition: dji_ack.cpp:38
The manager of psdk module.
Definition: dji_psdk_manager.hpp:41
Telemetry Subscription API for DJI OSDK library.
Drone/SDK Version definition for DJI onboardSDK library.
All DJI OSDK ACK parsing.
Implementation of the manager for psdk module.
Class providing APIs & data structures for acting as a MOP server.
Definition: dji_mop_server.hpp:43
Implementation of the manager for camera module.
Camera/Gimbal API for DJI onboardSDK library.
Status information for DJI Vehicle.
Implementation of flight controller.
Implementation of DJI Payload Device Abstraction.
Camera class for controlling camera-related functions available through open protocol.
Definition: dji_camera.hpp:49