sot-talos-balance  2.0.5
Collection of dynamic-graph entities aimed at implementing balance control on talos.
RTPacket.h
Go to the documentation of this file.
1 #ifndef RTPACKET_H
2 #define RTPACKET_H
3 
4 #include <stdint.h>
5 #include <stdio.h>
6 
7 #ifdef EXPORT_DLL
8 #define DLL_EXPORT __declspec(dllexport)
9 #else
10 #define DLL_EXPORT
11 #endif
12 
13 #define MAJOR_VERSION 1
14 #define MINOR_VERSION 19
15 
16 #define MAX_CAMERA_COUNT 256
17 #define MAX_ANALOG_DEVICE_COUNT 64
18 #define MAX_FORCE_PLATE_COUNT 64
19 #define MAX_GAZE_VECTOR_COUNT 64
20 #define MAX_TIMECODE_COUNT 3
21 #define MAX_SKELETON_COUNT 10
22 
24  public:
25  enum EPacketType {
26  PacketError = 0,
27  PacketCommand = 1,
28  PacketXML = 2,
29  PacketData = 3,
30  PacketNoMoreData = 4,
31  PacketC3DFile = 5,
32  PacketEvent = 6,
33  PacketDiscover = 7,
34  PacketQTMFile = 8,
35  PacketNone = 9
36  };
37 
39  Component3d = 1,
40  Component3dNoLabels = 2,
41  ComponentAnalog = 3,
42  ComponentForce = 4,
43  Component6d = 5,
44  Component6dEuler = 6,
45  Component2d = 7,
46  Component2dLin = 8,
47  Component3dRes = 9,
48  Component3dNoLabelsRes = 10,
49  Component6dRes = 11,
50  Component6dEulerRes = 12,
51  ComponentAnalogSingle = 13,
52  ComponentImage = 14,
53  ComponentForceSingle = 15,
54  ComponentGazeVector = 16,
55  ComponentTimecode = 17,
56  ComponentSkeleton = 18,
57  ComponentNone = 19
58  };
59 
60  enum EImageFormat {
61  FormatRawGrayscale = 0,
62  FormatRawBGR = 1,
63  FormatJPG = 2,
64  FormatPNG = 3
65  };
66 
67  enum EEvent {
68  EventConnected = 1,
69  EventConnectionClosed = 2,
70  EventCaptureStarted = 3,
71  EventCaptureStopped = 4,
72  EventCaptureFetchingFinished = 5, // Not used in version 1.10 and later
73  EventCalibrationStarted = 6,
74  EventCalibrationStopped = 7,
75  EventRTfromFileStarted = 8,
76  EventRTfromFileStopped = 9,
77  EventWaitingForTrigger = 10,
78  EventCameraSettingsChanged = 11,
79  EventQTMShuttingDown = 12,
80  EventCaptureSaved = 13,
81  EventReprocessingStarted = 14,
82  EventReprocessingStopped = 15,
83  EventTrigger = 16,
84  EventNone = 17 // Must be the last. Not actually an event. Just used to
85  // cont number of events.
86  };
87 
89  TimecodeSMPTE = 0,
90  TimecodeIRIG = 1,
91  TimecodeCamerTime = 2
92  };
93 
94  struct SForce {
95  float fForceX;
96  float fForceY;
97  float fForceZ;
98  float fMomentX;
99  float fMomentY;
100  float fMomentZ;
104  };
105 
106  struct SGazeVector {
107  float fX;
108  float fY;
109  float fZ;
110  float fPosX;
111  float fPosY;
112  float fPosZ;
113  };
114 
116  unsigned int id;
117  float positionX;
118  float positionY;
119  float positionZ;
120  float rotationX;
121  float rotationY;
122  float rotationZ;
123  float rotationW;
124  };
125 
126  public:
127  CRTPacket(int nMajorVersion = MAJOR_VERSION,
128  int nMinorVersion = MINOR_VERSION, bool bBigEndian = false);
129  void GetVersion(unsigned int &nMajorVersion, unsigned int &nMinorVersion);
130  void SetVersion(unsigned int nMajorVersion, unsigned int nMinorVersion);
131  bool GetEndianness();
132  void SetEndianness(bool bBigEndian);
133  void ClearData();
134  void SetData(char *ptr);
135  void GetData(char *&ptr, unsigned int &nSize);
136 
137  unsigned int GetSize();
138  EPacketType GetType();
139  unsigned long long GetTimeStamp();
140  unsigned int GetFrameNumber();
141  static unsigned int GetSize(char *pData, bool bBigEndian = false);
142  static EPacketType GetType(char *pData, bool bBigEndian = false);
143  static unsigned long long GetTimeStamp(char *pData, bool bBigEndian = false);
144  static unsigned int GetFrameNumber(char *pData, bool bBigEndian = false);
145 
146  unsigned int GetComponentCount();
147  unsigned int GetComponentSize(EComponentType eComponent);
148 
149  char *GetErrorString();
150  char *GetCommandString();
151  static char *GetCommandString(char *pData, bool bBigEndian = false);
152  char *GetXMLString();
153  bool GetEvent(EEvent &eEvent);
154  static bool GetEvent(EEvent &eEvent, char *pData, bool bBigEndian = false);
155  short GetDiscoverResponseBasePort();
156  static short GetDiscoverResponseBasePort(char *pData,
157  bool bBigEndian = false);
158 
159  unsigned short GetDropRate();
160  unsigned short GetOutOfSyncRate();
161 
162  unsigned int Get2DCameraCount();
163  unsigned int Get2DMarkerCount(unsigned int nCameraIndex);
164  unsigned char Get2DStatusFlags(unsigned int nCameraIndex);
165  bool Get2DMarker(unsigned int nCameraIndex, unsigned int nMarkerIndex,
166  unsigned int &nX, unsigned int &nY,
167  unsigned short &nXDiameter, unsigned short &nYDiameter);
168 
169  unsigned int Get2DLinCameraCount();
170  unsigned int Get2DLinMarkerCount(unsigned int nCameraIndex);
171  unsigned char Get2DLinStatusFlags(unsigned int nCameraIndex);
172  bool Get2DLinMarker(unsigned int nCameraIndex, unsigned int nMarkerIndex,
173  unsigned int &nX, unsigned int &nY,
174  unsigned short &nXDiameter, unsigned short &nYDiameter);
175 
176  unsigned int Get3DMarkerCount();
177  bool Get3DMarker(unsigned int nMarkerIndex, float &fX, float &fY, float &fZ);
178 
179  unsigned int Get3DResidualMarkerCount();
180  bool Get3DResidualMarker(unsigned int nMarkerIndex, float &fX, float &fY,
181  float &fZ, float &fResidual);
182 
183  unsigned int Get3DNoLabelsMarkerCount();
184  bool Get3DNoLabelsMarker(unsigned int nMarkerIndex, float &fX, float &fY,
185  float &fZ, unsigned int &nId);
186 
187  unsigned int Get3DNoLabelsResidualMarkerCount();
188  bool Get3DNoLabelsResidualMarker(unsigned int nMarkerIndex, float &fX,
189  float &fY, float &fZ, unsigned int &nId,
190  float &fResidual);
191 
192  unsigned int Get6DOFBodyCount();
193  bool Get6DOFBody(unsigned int nBodyIndex, float &fX, float &fY, float &fZ,
194  float afRotMatrix[9]);
195 
196  unsigned int Get6DOFResidualBodyCount();
197  bool Get6DOFResidualBody(unsigned int nBodyIndex, float &fX, float &fY,
198  float &fZ, float afRotMatrix[9], float &fResidual);
199 
200  unsigned int Get6DOFEulerBodyCount();
201  bool Get6DOFEulerBody(unsigned int nBodyIndex, float &fX, float &fY,
202  float &fZ, float &fAng1, float &fAng2, float &fAng3);
203 
204  unsigned int Get6DOFEulerResidualBodyCount();
205  bool Get6DOFEulerResidualBody(unsigned int nBodyIndex, float &fX, float &fY,
206  float &fZ, float &fAng1, float &fAng2,
207  float &fAng3, float &fResidual);
208 
209  unsigned int GetGazeVectorCount();
210  unsigned int GetGazeVectorSampleCount(unsigned int nVectorIndex);
211  unsigned int GetGazeVectorSampleNumber(
212  unsigned int nVectorIndex); // Returns 0 if no sample was found.
213  bool GetGazeVector(unsigned int nVectorIndex, unsigned int nSampleIndex,
214  SGazeVector &nGazeVector);
215  bool GetGazeVector(unsigned int nVectorIndex, SGazeVector *pGazeVectorBuf,
216  unsigned int nBufSize);
217 
218  unsigned int GetTimecodeCount();
219  bool GetTimecodeType(unsigned int nTimecodeIndex,
220  CRTPacket::ETimecodeType &timecodeType);
221  bool GetTimecodeSMPTE(unsigned int nTimecodeIndex, int &hours, int &minutes,
222  int &seconds, int &frame);
223  bool GetTimecodeIRIG(unsigned int nTimecodeIndex, int &year, int &day,
224  int &hours, int &minutes, int &seconds, int &tenths);
225  bool GetTimecodeCameraTime(unsigned int nTimecodeIndex,
226  unsigned long long &cameraTime);
227 
228  unsigned int GetImageCameraCount();
229  unsigned int GetImageCameraId(unsigned int nCameraIndex);
230  bool GetImageFormat(unsigned int nCameraIndex, EImageFormat &eImageFormat);
231  bool GetImageSize(unsigned int nCameraIndex, unsigned int &nWidth,
232  unsigned int &nHeight);
233  bool GetImageCrop(unsigned int nCameraIndex, float &fCropLeft,
234  float &fCropTop, float &fCropRight, float &fCropBottom);
235  unsigned int GetImageSize(unsigned int nCameraIndex);
236  unsigned int GetImage(unsigned int nCameraIndex, char *pDataBuf,
237  unsigned int nBufSize);
238 
239  unsigned int GetAnalogDeviceCount();
240  unsigned int GetAnalogDeviceId(unsigned int nDeviceIndex);
241  unsigned int GetAnalogChannelCount(unsigned int nDeviceIndex);
242  unsigned int GetAnalogSampleCount(unsigned int nDeviceIndex);
243  unsigned int GetAnalogSampleNumber(
244  unsigned int nDeviceIndex); // Returns 0 if no sample was found.
245  unsigned int GetAnalogData(unsigned int nDeviceIndex, float *pDataBuf,
246  unsigned int nBufSize);
247  unsigned int GetAnalogData(unsigned int nDeviceIndex,
248  unsigned int nChannelIndex, float *pDataBuf,
249  unsigned int nBufSize);
250  bool GetAnalogData(unsigned int nDeviceIndex, unsigned int nChannelIndex,
251  unsigned int nSampleIndex, float &fAnalogValue);
252 
253  unsigned int GetAnalogSingleDeviceCount();
254  unsigned int GetAnalogSingleDeviceId(unsigned int nDeviceIndex);
255  unsigned int GetAnalogSingleChannelCount(unsigned int nDeviceIndex);
256  unsigned int GetAnalogSingleData(unsigned int nDeviceIndex, float *pDataBuf,
257  unsigned int nBufSize);
258  bool GetAnalogSingleData(unsigned int nDeviceIndex,
259  unsigned int nChannelIndex, float &fValue);
260 
261  unsigned int GetForcePlateCount();
262  unsigned int GetForcePlateId(unsigned int nPlateIndex);
263  unsigned int GetForceCount(unsigned int nPlateIndex);
264  unsigned int GetForceNumber(
265  unsigned int nPlateIndex); // Returns 0 if no force was found.
266  unsigned int GetForceData(unsigned int nPlateIndex, SForce *pForceBuf,
267  unsigned int nBufSize);
268  bool GetForceData(unsigned int nPlateIndex, unsigned int nForceIndex,
269  SForce &sForce);
270 
271  unsigned int GetForceSinglePlateCount();
272  unsigned int GetForceSinglePlateId(unsigned int nPlateIndex);
273  bool GetForceSingleData(unsigned int nPlateIndex, SForce &pForce);
274 
275  unsigned int GetSkeletonCount();
276  unsigned int GetSkeletonSegmentCount(unsigned int nSkeletonIndex);
277  bool GetSkeletonSegments(unsigned int nSkeletonIndex,
278  SSkeletonSegment *segmentBuf, unsigned int nBufSize);
279  bool GetSkeletonSegment(unsigned int nSkeletonIndex, unsigned segmentIndex,
280  SSkeletonSegment &segment);
281 
282  private:
283  float SetByteOrder(float *pfData);
284  double SetByteOrder(double *pfData);
285  short SetByteOrder(short *pnData);
286  unsigned short SetByteOrder(unsigned short *pnData);
287  long SetByteOrder(long *pnData);
288  int SetByteOrder(int *pnData);
289  unsigned int SetByteOrder(unsigned int *pnData);
290  long long SetByteOrder(long long *pnData);
291  unsigned long long SetByteOrder(unsigned long long *pnData);
292 
293  private:
294  char *mpData;
295  char *mpComponentData[ComponentNone];
296  char *mp2DData[MAX_CAMERA_COUNT];
297  char *mp2DLinData[MAX_CAMERA_COUNT];
298  char *mpImageData[MAX_CAMERA_COUNT];
299  char *mpAnalogData[MAX_ANALOG_DEVICE_COUNT];
300  char *mpAnalogSingleData[MAX_ANALOG_DEVICE_COUNT];
301  char *mpForceData[MAX_FORCE_PLATE_COUNT];
302  char *mpForceSingleData[MAX_FORCE_PLATE_COUNT];
303  char *mpGazeVectorData[MAX_GAZE_VECTOR_COUNT];
304  char *mpTimecodeData[MAX_TIMECODE_COUNT];
305  char *mpSkeletonData[MAX_SKELETON_COUNT];
306  unsigned int mnComponentCount;
307  EComponentType meComponentType;
308  unsigned int mn2DCameraCount;
309  unsigned int mn2DLinCameraCount;
310  unsigned int mnImageCameraCount;
311  unsigned int mnAnalogDeviceCount;
312  unsigned int mnAnalogSingleDeviceCount;
313  unsigned int mnForcePlateCount;
314  unsigned int mnForceSinglePlateCount;
315  unsigned int mnGazeVectorCount;
316  unsigned int mnTimecodeCount;
317  unsigned int mSkeletonCount;
318  int mnMajorVersion;
319  int mnMinorVersion;
320  bool mbBigEndian;
321 }; // RTPacket
322 
323 #endif // RTPACKET_H
CRTPacket::EImageFormat
EImageFormat
Definition: RTPacket.h:60
CRTPacket::SSkeletonSegment::positionY
float positionY
Definition: RTPacket.h:118
MAX_FORCE_PLATE_COUNT
#define MAX_FORCE_PLATE_COUNT
Definition: RTPacket.h:18
CRTPacket::SForce::fApplicationPointX
float fApplicationPointX
Definition: RTPacket.h:101
CRTPacket::SForce::fForceY
float fForceY
Definition: RTPacket.h:96
CRTPacket::SSkeletonSegment::positionZ
float positionZ
Definition: RTPacket.h:119
CRTPacket::SGazeVector
Definition: RTPacket.h:106
MAJOR_VERSION
#define MAJOR_VERSION
Definition: RTPacket.h:13
CRTPacket::EPacketType
EPacketType
Definition: RTPacket.h:25
MAX_SKELETON_COUNT
#define MAX_SKELETON_COUNT
Definition: RTPacket.h:21
CRTPacket::SSkeletonSegment::rotationX
float rotationX
Definition: RTPacket.h:120
MINOR_VERSION
#define MINOR_VERSION
Definition: RTPacket.h:14
CRTPacket::SForce::fApplicationPointY
float fApplicationPointY
Definition: RTPacket.h:102
CRTPacket::SSkeletonSegment::rotationW
float rotationW
Definition: RTPacket.h:123
CRTPacket::SGazeVector::fX
float fX
Definition: RTPacket.h:107
CRTPacket::SSkeletonSegment::rotationY
float rotationY
Definition: RTPacket.h:121
CRTPacket::SSkeletonSegment::id
unsigned int id
Definition: RTPacket.h:116
CRTPacket::SSkeletonSegment
Definition: RTPacket.h:115
CRTPacket::ETimecodeType
ETimecodeType
Definition: RTPacket.h:88
CRTPacket::EEvent
EEvent
Definition: RTPacket.h:67
CRTPacket::SForce
Definition: RTPacket.h:94
CRTPacket::SSkeletonSegment::rotationZ
float rotationZ
Definition: RTPacket.h:122
CRTPacket::EComponentType
EComponentType
Definition: RTPacket.h:38
CRTPacket::SGazeVector::fPosX
float fPosX
Definition: RTPacket.h:110
MAX_ANALOG_DEVICE_COUNT
#define MAX_ANALOG_DEVICE_COUNT
Definition: RTPacket.h:17
CRTPacket::SGazeVector::fZ
float fZ
Definition: RTPacket.h:109
MAX_TIMECODE_COUNT
#define MAX_TIMECODE_COUNT
Definition: RTPacket.h:20
CRTPacket::SForce::fApplicationPointZ
float fApplicationPointZ
Definition: RTPacket.h:103
CRTPacket::SGazeVector::fPosY
float fPosY
Definition: RTPacket.h:111
CRTPacket::SGazeVector::fPosZ
float fPosZ
Definition: RTPacket.h:112
DLL_EXPORT
#define DLL_EXPORT
Definition: RTPacket.h:10
MAX_GAZE_VECTOR_COUNT
#define MAX_GAZE_VECTOR_COUNT
Definition: RTPacket.h:19
CRTPacket::SGazeVector::fY
float fY
Definition: RTPacket.h:108
CRTPacket::SForce::fForceZ
float fForceZ
Definition: RTPacket.h:97
CRTPacket::SForce::fMomentZ
float fMomentZ
Definition: RTPacket.h:100
CRTPacket
Definition: RTPacket.h:23
MAX_CAMERA_COUNT
#define MAX_CAMERA_COUNT
Definition: RTPacket.h:16
CRTPacket::SSkeletonSegment::positionX
float positionX
Definition: RTPacket.h:117
CRTPacket::SForce::fForceX
float fForceX
Definition: RTPacket.h:95
CRTPacket::SForce::fMomentY
float fMomentY
Definition: RTPacket.h:99
CRTPacket::SForce::fMomentX
float fMomentX
Definition: RTPacket.h:98