DJI Onboard SDK  4.0
dji_advanced_sensing_protocol.hpp
Go to the documentation of this file.
1 
12 #ifndef ONBOARDSDK_DJI_ADVANCED_SENSING_PROTOCOL_H
13 #define ONBOARDSDK_DJI_ADVANCED_SENSING_PROTOCOL_H
14 
15 #include "dji_hard_driver.hpp"
16 #include "dji_thread_manager.hpp"
17 #include "dji_protocol_base.hpp"
18 #include "linux_usb_device.hpp"
19 #include "dji_ack.hpp"
20 
26 #include "posix_thread_manager.hpp"
28 #include <cstring>
29 
30 namespace DJI
31 {
32 namespace OSDK
33 {
34 
35 class AdvancedSensingProtocol : public ProtocolBase
36 {
37 public:
38  enum CMDID
39  {
40  START_CMD_ID = 0x09,
41  SELECT_IMG_CMD_ID = 0x00,
42  PROCESS_IMG_CMD_ID = 0x01,
43  SELECT_VGA_IMG_CMD_ID = 0x31,
44  PROCESS_VGA_CMD_ID = 0x2F,
45  };
46 
47  enum VisionSensorDirection
48  {
49  DOWN = 0x00,
50  FRONT = 0x01,
51  BACK = 0x03,
52  LEFT = 0x00,
53  RIGHT = 0x01,
54  DISPARITY = 0x05,
55  };
56 
57  enum FREQ
58  {
59  FREQ_10HZ = 0x01,
60  FREQ_20HZ = 0x00,
61  };
62 
63 public:
65  AdvancedSensingProtocol();
66 
68  ~AdvancedSensingProtocol();
69 
70  /************************** Init ******************************************/
71 public:
72  void init(HardDriver* Driver, MMU* mmuPtr, bool userCallbackThread = false);
73 
74  /********************* Useful protocol related constants ******************/
75  static const uint8_t SOF1 = 0x55;
76  static const uint8_t SOF2 = 0xaa;
77  // max 5 pairs of stereo camera (2*BW_imgs + 1*depth) 240p
78  // plus header_len: 12, metadata: 8, img_desc: 200
79  static const int USB_MAXRECV = 5*(2+1)*240*320 + 12 + 8 + 200;
80 
81 
82  /*******************************Send Pipeline*****************************/
83 public:
84  int formatProtocol(uint8_t *dst, uint8_t cmd_id,
85  uint8_t *data, uint32_t data_size);
86 
87  int send(void *cmd, void *data, uint16_t data_len);
88 
89 private:
90  int sendInterface(void *in_cmd_container);
91 
92  int sendData(uint8_t *buf);
93 
94  int sendWithLen(void *data, int data_len);
95 
96  /************************** Receive Pipeline ******************************/
97 private:
99 
102  bool checkStream();
103 
106  bool verifyHead();
107 
110  bool verifyData();
111 
114  bool callApp();
115 
118  bool appHandler(void *protocolHeader);
119 
120  /********************************** CRC **********************************/
121 private:
122  int crcHeadCheck(uint8_t* pMsg, size_t nLen);
123 
124  int crcTailCheck(uint8_t* pMsg, size_t nLen);
125 
126 /******************************* Member variables ************************/
127 private:
128  ACK::StereoImgData *stereoImgData;
129  ACK::StereoVGAImgData *stereoVGAImgData;
130 
131 }; // class AdvancedSensingProtocol
132 
133 } // namespace OSDK
134 } // namespace DJI
135 
136 #endif //ONBOARDSDK_DJI_ADVANCED_SENSING_PROTOCOL_H
Serial device driver abstraction. Provided as an abstract class. Please inherit and implement for ind...
Data protection and thread management abstract classes.
Abstract protocol implementation for DJI OSDK.
struct DJI::OSDK::ACK::StereoVGAImgData StereoVGAImgData
This struct captures PushData when subscribe to VGA images.
handle array of characters
Definition: commondatarangehandler.h:14
All DJI OSDK ACK parsing.
Thread safety and data protection for DJI Onboard SDK on linux platforms.
struct DJI::OSDK::ACK::StereoImgData StereoImgData
This struct captures PushData when subscribe to QVGA images.