dji_perception.hpp
Go to the documentation of this file.
1 
29 #ifndef ONBOARDSDK_DJI_PERCEPTION_H
30 #define ONBOARDSDK_DJI_PERCEPTION_H
31 
32 #include "cstring"
33 #include "stdint.h"
34 
35 #define IMAGE_MAX_DIRECTION_NUM (6)
36 
37 namespace DJI {
38 namespace OSDK {
39 
40 // Forward Declaration
41 class Vehicle;
42 class PerceptionImpl;
43 
44 class Perception {
45  public:
46  Perception(Vehicle *vehiclePtr);
47 
48  ~Perception();
49 
50  public:
51 
52  typedef enum {
53  OSDK_PERCEPTION_PASS = 0,
54  OSDK_PERCEPTION_TIMEOUT = 1,
55  OSDK_PERCEPTION_SUBSCRIBE_FAIL = 2,
56  OSDK_PERCEPTION_PARAM_ERR = 3,
57  OSDK_PERCEPTION_REQ_REFUSED = 4,
58  OSDK_PERCEPTION_REQ_UNSUPPORT = 5,
59  OSDK_LIVEVIEW_UNKNOWN = 0xFF,
60  } PerceptionErrCode;
61 
62  typedef enum CamPositionType : uint32_t {
63  RECTIFY_DOWN_LEFT = 1,
64  RAW_DOWN_FRONT = RECTIFY_DOWN_LEFT, //only for M210V2
65  RECTIFY_DOWN_RIGHT = 2,
66  RAW_DOWN_BACK = RECTIFY_DOWN_RIGHT, //only for M210V2
67  RECTIFY_FRONT_LEFT = 3,
68  RAW_FRONT_LEFT = RECTIFY_FRONT_LEFT, //only for M210V2
69  RECTIFY_FRONT_RIGHT = 4,
70  RAW_FRONT_RIGHT = RECTIFY_FRONT_RIGHT, //only for M210V2
71  RECTIFY_REAR_LEFT = 5,
72  RECTIFY_REAR_RIGHT = 6,
73  RECTIFY_UP_LEFT = 21,
74  RECTIFY_UP_RIGHT = 22,
75  RECTIFY_LEFT_LEFT = 23,
76  RECTIFY_LEFT_RIGHT = 24,
77  RECTIFY_RIGHT_LEFT = 25,
78  RECTIFY_RIGHT_RIGHT = 26
79  } CamPositionType;
80 
81  typedef enum DirectionType : uint8_t {
82  RECTIFY_DOWN = 0,
83  RECTIFY_FRONT = 1,
84  RECTIFY_REAR = 2,
85  RECTIFY_UP = 3,
86  RECTIFY_LEFT = 4,
87  RECTIFY_RIGHT = 5
88  } DirectionType;
89 
90 #pragma pack(1)
91  typedef struct RawImageInfoType {
92  uint32_t index;
93  DirectionType direction;
94  uint8_t bpp;
95  uint32_t width;
96  uint32_t height;
97  } RawImageInfoType;
98 
99  typedef struct ImageInfoType {
100  RawImageInfoType rawInfo;
101  uint16_t dataId;
102  uint16_t sequence;
103  CamPositionType dataType;
104  uint64_t timeStamp;
105  } ImageInfoType;
106 
107  typedef struct CamParamType {
108  DirectionType direction;
109  float leftIntrinsics[9];
110  float rightIntrinsics[9];
111  float rotaionLeftInRight[9];
112  float translationLeftInRight[3];
113  } CamParamType;
114 
115  typedef struct {
116  uint32_t timeStamp;//ms
117  uint32_t directionNum;
118  CamParamType cameraParam[IMAGE_MAX_DIRECTION_NUM];
119  } CamParamPacketType;
120 #pragma pack()
121 
123  typedef void(*PerceptionCamParamCB)
124  (Perception::CamParamPacketType paramPacket, void *userData);
125 
127  typedef void(*PerceptionImageCB)
128  (Perception::ImageInfoType, uint8_t *imageRawBuffer, int bufferLen, void *userData);
129 
130  public:
131 
142  PerceptionErrCode subscribePerceptionImage(DirectionType direction, PerceptionImageCB cb, void* userData);
143 
152  PerceptionErrCode unsubscribePerceptionImage(DirectionType direction);
153 
161  PerceptionErrCode triggerStereoCamParamsPushing();
162 
171  void setStereoCamParamsObserver(PerceptionCamParamCB cb, void *userData);
172 
177  void cancelAllSubsciptions();
178 
179  private:
180  Vehicle *vehicle;
181  PerceptionImpl *impl;
182 };
183 } // OSDK
184 } // DJI
185 
186 #endif //ONBOARDSDK_DJI_PERCEPTION_H
Definition: dji_ack.cpp:38