sbgEComBinaryLogImu.c
Go to the documentation of this file.
1 #include "sbgEComBinaryLogImu.h"
2 
3 //----------------------------------------------------------------------//
4 //- Operations -//
5 //----------------------------------------------------------------------//
6 
14 {
15  //
16  // Check input arguments
17  //
18  SBG_ASSERT(pInputStream);
19  SBG_ASSERT(pOutputData);
20 
21  //
22  // Read the frame payload
23  //
24  pOutputData->timeStamp = sbgStreamBufferReadUint32LE(pInputStream);
25  pOutputData->status = sbgStreamBufferReadUint16LE(pInputStream);
26 
27  pOutputData->accelerometers[0] = sbgStreamBufferReadFloatLE(pInputStream);
28  pOutputData->accelerometers[1] = sbgStreamBufferReadFloatLE(pInputStream);
29  pOutputData->accelerometers[2] = sbgStreamBufferReadFloatLE(pInputStream);
30 
31  pOutputData->gyroscopes[0] = sbgStreamBufferReadFloatLE(pInputStream);
32  pOutputData->gyroscopes[1] = sbgStreamBufferReadFloatLE(pInputStream);
33  pOutputData->gyroscopes[2] = sbgStreamBufferReadFloatLE(pInputStream);
34 
35  pOutputData->temperature = sbgStreamBufferReadFloatLE(pInputStream);
36 
37  pOutputData->deltaVelocity[0] = sbgStreamBufferReadFloatLE(pInputStream);
38  pOutputData->deltaVelocity[1] = sbgStreamBufferReadFloatLE(pInputStream);
39  pOutputData->deltaVelocity[2] = sbgStreamBufferReadFloatLE(pInputStream);
40 
41  pOutputData->deltaAngle[0] = sbgStreamBufferReadFloatLE(pInputStream);
42  pOutputData->deltaAngle[1] = sbgStreamBufferReadFloatLE(pInputStream);
43  pOutputData->deltaAngle[2] = sbgStreamBufferReadFloatLE(pInputStream);
44 
45  //
46  // Return if any error has occurred while parsing the frame
47  //
48  return sbgStreamBufferGetLastError(pInputStream);
49 }
50 
58 {
59  //
60  // Check input arguments
61  //
62  SBG_ASSERT(pOutputStream);
63  SBG_ASSERT(pInputData);
64 
65  //
66  // Write the frame payload
67  //
68  sbgStreamBufferWriteUint32LE(pOutputStream, pInputData->timeStamp);
69  sbgStreamBufferWriteUint16LE(pOutputStream, pInputData->status);
70 
71  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->accelerometers[0]);
72  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->accelerometers[1]);
73  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->accelerometers[2]);
74 
75  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->gyroscopes[0]);
76  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->gyroscopes[1]);
77  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->gyroscopes[2]);
78 
79  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->temperature);
80 
81  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->deltaVelocity[0]);
82  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->deltaVelocity[1]);
83  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->deltaVelocity[2]);
84 
85  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->deltaAngle[0]);
86  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->deltaAngle[1]);
87  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->deltaAngle[2]);
88 
89  //
90  // Return if any error has occurred while writing the frame
91  //
92  return sbgStreamBufferGetLastError(pOutputStream);
93 }
94 
102 {
103  //
104  // Check input arguments
105  //
106  SBG_ASSERT(pInputStream);
107  SBG_ASSERT(pOutputData);
108 
109  //
110  // Read the frame payload
111  //
112  pOutputData->timeStamp = sbgStreamBufferReadUint32LE(pInputStream);
113  pOutputData->status = sbgStreamBufferReadUint16LE(pInputStream);
114 
115  pOutputData->accelerometers[0] = (float)sbgStreamBufferReadInt16LE(pInputStream) * 0.01f;
116  pOutputData->accelerometers[1] = (float)sbgStreamBufferReadInt16LE(pInputStream) * 0.01f;
117  pOutputData->accelerometers[2] = (float)sbgStreamBufferReadInt16LE(pInputStream) * 0.01f;
118 
119  pOutputData->gyroscopes[0] = (float)sbgStreamBufferReadInt16LE(pInputStream) * 0.001f;
120  pOutputData->gyroscopes[1] = (float)sbgStreamBufferReadInt16LE(pInputStream) * 0.001f;
121  pOutputData->gyroscopes[2] = (float)sbgStreamBufferReadInt16LE(pInputStream) * 0.001f;
122 
123  //
124  // Return if any error has occurred while parsing the frame
125  //
126  return sbgStreamBufferGetLastError(pInputStream);
127 }
128 
136 {
137  //
138  // Check input arguments
139  //
140  SBG_ASSERT(pOutputStream);
141  SBG_ASSERT(pInputData);
142 
143  //
144  // Write the frame payload
145  //
146  sbgStreamBufferWriteUint32LE(pOutputStream, pInputData->timeStamp);
147  sbgStreamBufferWriteUint16LE(pOutputStream, pInputData->status);
148 
149  sbgStreamBufferWriteInt16LE(pOutputStream, (int16)(pInputData->accelerometers[0] * 100.0f));
150  sbgStreamBufferWriteInt16LE(pOutputStream, (int16)(pInputData->accelerometers[1] * 100.0f));
151  sbgStreamBufferWriteInt16LE(pOutputStream, (int16)(pInputData->accelerometers[2] * 100.0f));
152 
153  sbgStreamBufferWriteInt16LE(pOutputStream, (int16)(pInputData->gyroscopes[0] * 1000.0f));
154  sbgStreamBufferWriteInt16LE(pOutputStream, (int16)(pInputData->gyroscopes[1] * 1000.0f));
155  sbgStreamBufferWriteInt16LE(pOutputStream, (int16)(pInputData->gyroscopes[2] * 1000.0f));
156 
157  //
158  // Return if any error has occurred while writing the frame
159  //
160  return sbgStreamBufferGetLastError(pOutputStream);
161 }
SBG_INLINE float sbgStreamBufferReadFloatLE(SbgStreamBuffer *pHandle)
SBG_INLINE int16 sbgStreamBufferReadInt16LE(SbgStreamBuffer *pHandle)
signed short int16
Definition: sbgTypes.h:63
SbgErrorCode sbgEComBinaryLogWriteFastImuData(SbgStreamBuffer *pOutputStream, const SbgLogFastImuData *pInputData)
SBG_INLINE uint16 sbgStreamBufferReadUint16LE(SbgStreamBuffer *pHandle)
SbgErrorCode sbgEComBinaryLogParseFastImuData(SbgStreamBuffer *pInputStream, SbgLogFastImuData *pOutputData)
SBG_INLINE uint32 sbgStreamBufferReadUint32LE(SbgStreamBuffer *pHandle)
SBG_INLINE SbgErrorCode sbgStreamBufferWriteInt16LE(SbgStreamBuffer *pHandle, int16 value)
SbgErrorCode sbgEComBinaryLogWriteImuData(SbgStreamBuffer *pOutputStream, const SbgLogImuData *pInputData)
SBG_INLINE SbgErrorCode sbgStreamBufferWriteUint16LE(SbgStreamBuffer *pHandle, uint16 value)
SBG_INLINE SbgErrorCode sbgStreamBufferWriteFloatLE(SbgStreamBuffer *pHandle, float value)
This file is used to parse received IMU binary logs.
SBG_INLINE SbgErrorCode sbgStreamBufferWriteUint32LE(SbgStreamBuffer *pHandle, uint32 value)
#define SBG_ASSERT(expression)
Definition: sbgDebug.h:52
SbgErrorCode sbgEComBinaryLogParseImuData(SbgStreamBuffer *pInputStream, SbgLogImuData *pOutputData)
enum _SbgErrorCode SbgErrorCode
SBG_INLINE SbgErrorCode sbgStreamBufferGetLastError(SbgStreamBuffer *pHandle)


sbg_driver
Author(s):
autogenerated on Sun Jan 27 2019 03:42:20