sbgEComBinaryLogImu.c
Go to the documentation of this file.
1 #include "sbgEComBinaryLogImu.h"
2 
3 //----------------------------------------------------------------------//
4 //- Getter / helpers -//
5 //----------------------------------------------------------------------//
6 
13 float sbgLogImuShortGetDeltaAngle(const SbgLogImuShort *pImuShort, size_t idx)
14 {
15  assert(pImuShort);
16  assert(idx < 3);
17 
18  return pImuShort->deltaAngle[idx] / 67108864.0f;
19 }
20 
27 float sbgLogImuShortGetDeltaVelocity(const SbgLogImuShort *pImuShort, size_t idx)
28 {
29  assert(pImuShort);
30  assert(idx < 3);
31 
32  return pImuShort->deltaVelocity[idx] / 1048576.0f;
33 }
34 
41 {
42  assert(pImuShort);
43 
44  return pImuShort->temperature / 256.0f;
45 }
46 
47 //----------------------------------------------------------------------//
48 //- Operations -//
49 //----------------------------------------------------------------------//
50 
58 {
59  assert(pInputStream);
60  assert(pOutputData);
61 
62  //
63  // Read the frame payload
64  //
65  pOutputData->timeStamp = sbgStreamBufferReadUint32LE(pInputStream);
66  pOutputData->status = sbgStreamBufferReadUint16LE(pInputStream);
67 
68  pOutputData->accelerometers[0] = sbgStreamBufferReadFloatLE(pInputStream);
69  pOutputData->accelerometers[1] = sbgStreamBufferReadFloatLE(pInputStream);
70  pOutputData->accelerometers[2] = sbgStreamBufferReadFloatLE(pInputStream);
71 
72  pOutputData->gyroscopes[0] = sbgStreamBufferReadFloatLE(pInputStream);
73  pOutputData->gyroscopes[1] = sbgStreamBufferReadFloatLE(pInputStream);
74  pOutputData->gyroscopes[2] = sbgStreamBufferReadFloatLE(pInputStream);
75 
76  pOutputData->temperature = sbgStreamBufferReadFloatLE(pInputStream);
77 
78  pOutputData->deltaVelocity[0] = sbgStreamBufferReadFloatLE(pInputStream);
79  pOutputData->deltaVelocity[1] = sbgStreamBufferReadFloatLE(pInputStream);
80  pOutputData->deltaVelocity[2] = sbgStreamBufferReadFloatLE(pInputStream);
81 
82  pOutputData->deltaAngle[0] = sbgStreamBufferReadFloatLE(pInputStream);
83  pOutputData->deltaAngle[1] = sbgStreamBufferReadFloatLE(pInputStream);
84  pOutputData->deltaAngle[2] = sbgStreamBufferReadFloatLE(pInputStream);
85 
86  //
87  // Return if any error has occurred while parsing the frame
88  //
89  return sbgStreamBufferGetLastError(pInputStream);
90 }
91 
99 {
100  assert(pOutputStream);
101  assert(pInputData);
102 
103  //
104  // Write the frame payload
105  //
106  sbgStreamBufferWriteUint32LE(pOutputStream, pInputData->timeStamp);
107  sbgStreamBufferWriteUint16LE(pOutputStream, pInputData->status);
108 
109  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->accelerometers[0]);
110  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->accelerometers[1]);
111  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->accelerometers[2]);
112 
113  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->gyroscopes[0]);
114  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->gyroscopes[1]);
115  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->gyroscopes[2]);
116 
117  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->temperature);
118 
119  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->deltaVelocity[0]);
120  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->deltaVelocity[1]);
121  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->deltaVelocity[2]);
122 
123  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->deltaAngle[0]);
124  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->deltaAngle[1]);
125  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->deltaAngle[2]);
126 
127  //
128  // Return if any error has occurred while writing the frame
129  //
130  return sbgStreamBufferGetLastError(pOutputStream);
131 }
132 
140 {
141  assert(pInputStream);
142  assert(pOutputData);
143 
144  //
145  // Read the frame payload
146  //
147  pOutputData->timeStamp = sbgStreamBufferReadUint32LE(pInputStream);
148  pOutputData->status = sbgStreamBufferReadUint16LE(pInputStream);
149 
150  pOutputData->deltaVelocity[0] = sbgStreamBufferReadInt32LE(pInputStream);
151  pOutputData->deltaVelocity[1] = sbgStreamBufferReadInt32LE(pInputStream);
152  pOutputData->deltaVelocity[2] = sbgStreamBufferReadInt32LE(pInputStream);
153 
154  pOutputData->deltaAngle[0] = sbgStreamBufferReadInt32LE(pInputStream);
155  pOutputData->deltaAngle[1] = sbgStreamBufferReadInt32LE(pInputStream);
156  pOutputData->deltaAngle[2] = sbgStreamBufferReadInt32LE(pInputStream);
157 
158  pOutputData->temperature = sbgStreamBufferReadInt16LE(pInputStream);
159 
160  //
161  // Return if any error has occurred while parsing the frame
162  //
163  return sbgStreamBufferGetLastError(pInputStream);
164 }
165 
173 {
174  assert(pOutputStream);
175  assert(pInputData);
176 
177  //
178  // Write the frame payload
179  //
180  sbgStreamBufferWriteUint32LE(pOutputStream, pInputData->timeStamp);
181  sbgStreamBufferWriteUint16LE(pOutputStream, pInputData->status);
182 
183  sbgStreamBufferWriteInt32LE(pOutputStream, pInputData->deltaVelocity[0]);
184  sbgStreamBufferWriteInt32LE(pOutputStream, pInputData->deltaVelocity[1]);
185  sbgStreamBufferWriteInt32LE(pOutputStream, pInputData->deltaVelocity[2]);
186 
187  sbgStreamBufferWriteInt32LE(pOutputStream, pInputData->deltaAngle[0]);
188  sbgStreamBufferWriteInt32LE(pOutputStream, pInputData->deltaAngle[1]);
189  sbgStreamBufferWriteInt32LE(pOutputStream, pInputData->deltaAngle[2]);
190 
191  sbgStreamBufferWriteInt16LE(pOutputStream, pInputData->temperature);
192 
193  //
194  // Return if any error has occurred while writing the frame
195  //
196  return sbgStreamBufferGetLastError(pOutputStream);
197 }
198 
206 {
207  assert(pInputStream);
208  assert(pOutputData);
209 
210  //
211  // Read the frame payload
212  //
213  pOutputData->timeStamp = sbgStreamBufferReadUint32LE(pInputStream);
214  pOutputData->status = sbgStreamBufferReadUint16LE(pInputStream);
215 
216  pOutputData->accelerometers[0] = (float)sbgStreamBufferReadInt16LE(pInputStream) * 0.01f;
217  pOutputData->accelerometers[1] = (float)sbgStreamBufferReadInt16LE(pInputStream) * 0.01f;
218  pOutputData->accelerometers[2] = (float)sbgStreamBufferReadInt16LE(pInputStream) * 0.01f;
219 
220  pOutputData->gyroscopes[0] = (float)sbgStreamBufferReadInt16LE(pInputStream) * 0.001f;
221  pOutputData->gyroscopes[1] = (float)sbgStreamBufferReadInt16LE(pInputStream) * 0.001f;
222  pOutputData->gyroscopes[2] = (float)sbgStreamBufferReadInt16LE(pInputStream) * 0.001f;
223 
224  //
225  // Return if any error has occurred while parsing the frame
226  //
227  return sbgStreamBufferGetLastError(pInputStream);
228 }
229 
237 {
238  assert(pOutputStream);
239  assert(pInputData);
240 
241  //
242  // Write the frame payload
243  //
244  sbgStreamBufferWriteUint32LE(pOutputStream, pInputData->timeStamp);
245  sbgStreamBufferWriteUint16LE(pOutputStream, pInputData->status);
246 
247  sbgStreamBufferWriteInt16LE(pOutputStream, (int16_t)(pInputData->accelerometers[0] * 100.0f));
248  sbgStreamBufferWriteInt16LE(pOutputStream, (int16_t)(pInputData->accelerometers[1] * 100.0f));
249  sbgStreamBufferWriteInt16LE(pOutputStream, (int16_t)(pInputData->accelerometers[2] * 100.0f));
250 
251  sbgStreamBufferWriteInt16LE(pOutputStream, (int16_t)(pInputData->gyroscopes[0] * 1000.0f));
252  sbgStreamBufferWriteInt16LE(pOutputStream, (int16_t)(pInputData->gyroscopes[1] * 1000.0f));
253  sbgStreamBufferWriteInt16LE(pOutputStream, (int16_t)(pInputData->gyroscopes[2] * 1000.0f));
254 
255  //
256  // Return if any error has occurred while writing the frame
257  //
258  return sbgStreamBufferGetLastError(pOutputStream);
259 }
SBG_INLINE float sbgStreamBufferReadFloatLE(SbgStreamBuffer *pHandle)
SBG_INLINE SbgErrorCode sbgStreamBufferWriteInt16LE(SbgStreamBuffer *pHandle, int16_t value)
SbgErrorCode sbgEComBinaryLogParseImuShort(SbgStreamBuffer *pInputStream, SbgLogImuShort *pOutputData)
int32_t deltaVelocity[3]
SbgErrorCode sbgEComBinaryLogWriteFastImuData(SbgStreamBuffer *pOutputStream, const SbgLogFastImuData *pInputData)
SbgErrorCode sbgEComBinaryLogWriteImuShort(SbgStreamBuffer *pOutputStream, const SbgLogImuShort *pInputData)
SBG_INLINE uint16_t sbgStreamBufferReadUint16LE(SbgStreamBuffer *pHandle)
float sbgLogImuShortGetTemperature(const SbgLogImuShort *pImuShort)
SbgErrorCode sbgEComBinaryLogParseFastImuData(SbgStreamBuffer *pInputStream, SbgLogFastImuData *pOutputData)
SbgErrorCode sbgEComBinaryLogWriteImuData(SbgStreamBuffer *pOutputStream, const SbgLogImuData *pInputData)
SBG_INLINE SbgErrorCode sbgStreamBufferWriteInt32LE(SbgStreamBuffer *pHandle, int32_t value)
SBG_INLINE SbgErrorCode sbgStreamBufferWriteFloatLE(SbgStreamBuffer *pHandle, float value)
SBG_INLINE int32_t sbgStreamBufferReadInt32LE(SbgStreamBuffer *pHandle)
This file is used to parse received IMU binary logs.
SbgErrorCode sbgEComBinaryLogParseImuData(SbgStreamBuffer *pInputStream, SbgLogImuData *pOutputData)
SBG_INLINE SbgErrorCode sbgStreamBufferWriteUint32LE(SbgStreamBuffer *pHandle, uint32_t value)
SBG_INLINE uint32_t sbgStreamBufferReadUint32LE(SbgStreamBuffer *pHandle)
SBG_INLINE SbgErrorCode sbgStreamBufferWriteUint16LE(SbgStreamBuffer *pHandle, uint16_t value)
float sbgLogImuShortGetDeltaVelocity(const SbgLogImuShort *pImuShort, size_t idx)
float sbgLogImuShortGetDeltaAngle(const SbgLogImuShort *pImuShort, size_t idx)
enum _SbgErrorCode SbgErrorCode
SBG_INLINE int16_t sbgStreamBufferReadInt16LE(SbgStreamBuffer *pHandle)
SBG_INLINE SbgErrorCode sbgStreamBufferGetLastError(SbgStreamBuffer *pHandle)


sbg_driver
Author(s): SBG Systems
autogenerated on Sat Sep 3 2022 02:53:35