@@ -36,10 +36,10 @@ PolledBno055::PolledBno055(std::string name, std::string hubName, const oni_dev_
3636 " Bosch Bno055 9-axis inertial measurement unit (IMU) Euler angle" ,
3737 streamIdentifier,
3838 3 ,
39- sampleRate ,
39+ SampleRate ,
4040 " Eul" ,
4141 ContinuousChannel::Type::AUX,
42- eulerAngleScale ,
42+ EulerAngleScale ,
4343 " Degrees" ,
4444 { " Y" , " R" , " P" },
4545 " euler" ,
@@ -52,10 +52,10 @@ PolledBno055::PolledBno055(std::string name, std::string hubName, const oni_dev_
5252 " Bosch Bno055 9-axis inertial measurement unit (IMU) Quaternion" ,
5353 streamIdentifier,
5454 4 ,
55- sampleRate ,
55+ SampleRate ,
5656 " Quat" ,
5757 ContinuousChannel::Type::AUX,
58- quaternionScale ,
58+ QuaternionScale ,
5959 " " ,
6060 { " W" , " X" , " Y" , " Z" },
6161 " quaternion" ,
@@ -68,10 +68,10 @@ PolledBno055::PolledBno055(std::string name, std::string hubName, const oni_dev_
6868 " Bosch Bno055 9-axis inertial measurement unit (IMU) Acceleration" ,
6969 streamIdentifier,
7070 3 ,
71- sampleRate ,
71+ SampleRate ,
7272 " Acc" ,
7373 ContinuousChannel::Type::AUX,
74- accelerationScale ,
74+ AccelerationScale ,
7575 " m / s ^ 2" ,
7676 { " X" , " Y" , " Z" },
7777 " acceleration" ,
@@ -84,10 +84,10 @@ PolledBno055::PolledBno055(std::string name, std::string hubName, const oni_dev_
8484 " Bosch Bno055 9-axis inertial measurement unit (IMU) Gravity" ,
8585 streamIdentifier,
8686 3 ,
87- sampleRate ,
87+ SampleRate ,
8888 " Grav" ,
8989 ContinuousChannel::Type::AUX,
90- accelerationScale ,
90+ AccelerationScale ,
9191 " m/s^2" ,
9292 { " X" , " Y" , " Z" },
9393 " gravity" ,
@@ -100,7 +100,7 @@ PolledBno055::PolledBno055(std::string name, std::string hubName, const oni_dev_
100100 " Bosch Bno055 9-axis inertial measurement unit (IMU) Temperature" ,
101101 streamIdentifier,
102102 1 ,
103- sampleRate ,
103+ SampleRate ,
104104 " Temp" ,
105105 ContinuousChannel::Type::AUX,
106106 1 .0f ,
@@ -115,7 +115,7 @@ PolledBno055::PolledBno055(std::string name, std::string hubName, const oni_dev_
115115 " Bosch Bno055 9-axis inertial measurement unit (IMU) Calibration status" ,
116116 streamIdentifier,
117117 4 ,
118- sampleRate ,
118+ SampleRate ,
119119 " Cal" ,
120120 ContinuousChannel::Type::AUX,
121121 1 .0f ,
@@ -126,10 +126,15 @@ PolledBno055::PolledBno055(std::string name, std::string hubName, const oni_dev_
126126 );
127127 streamInfos.add (calibrationStatusStream);
128128
129- for (int i = 0 ; i < numFrames ; i++)
129+ for (int i = 0 ; i < NumFrames ; i++)
130130 eventCodes[i] = 0 ;
131131}
132132
133+ PolledBno055::~PolledBno055 ()
134+ {
135+ stopTimer ();
136+ }
137+
133138OnixDeviceType PolledBno055::getDeviceType ()
134139{
135140 return OnixDeviceType::POLLEDBNO;
@@ -174,7 +179,7 @@ bool PolledBno055::updateSettings()
174179 rc = WriteByte (0x3D , 0x0C ); // Operation mode is NDOF
175180 if (rc != ONI_ESUCCESS) return false ;
176181
177- rc = set933I2cRate (i2cRate );
182+ rc = set933I2cRate (I2cRate );
178183
179184 return rc == ONI_ESUCCESS;
180185}
@@ -203,7 +208,7 @@ void PolledBno055::addFrame(oni_frame_t* frame)
203208
204209void PolledBno055::addSourceBuffers (OwnedArray<DataBuffer>& sourceBuffers)
205210{
206- sourceBuffers.add (new DataBuffer (numberOfChannels , (int )sampleRate * bufferSizeInSeconds));
211+ sourceBuffers.add (new DataBuffer (NumberOfChannels , (int )SampleRate * bufferSizeInSeconds));
207212 bnoBuffer = sourceBuffers.getLast ();
208213}
209214
@@ -223,43 +228,43 @@ void PolledBno055::hiResTimerCallback()
223228 size_t offset = 0 ;
224229
225230 // Euler
226- bnoSamples[offset++ * numFrames + currentFrame] = readInt16 (EulerHeadingLsbAddress) * eulerAngleScale ;
227- bnoSamples[offset++ * numFrames + currentFrame] = readInt16 (EulerHeadingLsbAddress + 2 ) * eulerAngleScale ;
228- bnoSamples[offset++ * numFrames + currentFrame] = readInt16 (EulerHeadingLsbAddress + 4 ) * eulerAngleScale ;
231+ bnoSamples[offset++ * NumFrames + currentFrame] = readInt16 (EulerHeadingLsbAddress) * EulerAngleScale ;
232+ bnoSamples[offset++ * NumFrames + currentFrame] = readInt16 (EulerHeadingLsbAddress + 2 ) * EulerAngleScale ;
233+ bnoSamples[offset++ * NumFrames + currentFrame] = readInt16 (EulerHeadingLsbAddress + 4 ) * EulerAngleScale ;
229234
230235 // Quaternion
231- bnoSamples[offset++ * numFrames + currentFrame] = readInt16 (EulerHeadingLsbAddress + 6 ) * quaternionScale ;
232- bnoSamples[offset++ * numFrames + currentFrame] = readInt16 (EulerHeadingLsbAddress + 8 ) * quaternionScale ;
233- bnoSamples[offset++ * numFrames + currentFrame] = readInt16 (EulerHeadingLsbAddress + 10 ) * quaternionScale ;
234- bnoSamples[offset++ * numFrames + currentFrame] = readInt16 (EulerHeadingLsbAddress + 12 ) * quaternionScale ;
236+ bnoSamples[offset++ * NumFrames + currentFrame] = readInt16 (EulerHeadingLsbAddress + 6 ) * QuaternionScale ;
237+ bnoSamples[offset++ * NumFrames + currentFrame] = readInt16 (EulerHeadingLsbAddress + 8 ) * QuaternionScale ;
238+ bnoSamples[offset++ * NumFrames + currentFrame] = readInt16 (EulerHeadingLsbAddress + 10 ) * QuaternionScale ;
239+ bnoSamples[offset++ * NumFrames + currentFrame] = readInt16 (EulerHeadingLsbAddress + 12 ) * QuaternionScale ;
235240
236241 // Acceleration
237242
238- bnoSamples[offset++ * numFrames + currentFrame] = readInt16 (EulerHeadingLsbAddress + 14 ) * accelerationScale ;
239- bnoSamples[offset++ * numFrames + currentFrame] = readInt16 (EulerHeadingLsbAddress + 16 ) * accelerationScale ;
240- bnoSamples[offset++ * numFrames + currentFrame] = readInt16 (EulerHeadingLsbAddress + 18 ) * accelerationScale ;
243+ bnoSamples[offset++ * NumFrames + currentFrame] = readInt16 (EulerHeadingLsbAddress + 14 ) * AccelerationScale ;
244+ bnoSamples[offset++ * NumFrames + currentFrame] = readInt16 (EulerHeadingLsbAddress + 16 ) * AccelerationScale ;
245+ bnoSamples[offset++ * NumFrames + currentFrame] = readInt16 (EulerHeadingLsbAddress + 18 ) * AccelerationScale ;
241246
242247 // Gravity
243248
244- bnoSamples[offset++ * numFrames + currentFrame] = readInt16 (EulerHeadingLsbAddress + 20 ) * accelerationScale ;
245- bnoSamples[offset++ * numFrames + currentFrame] = readInt16 (EulerHeadingLsbAddress + 22 ) * accelerationScale ;
246- bnoSamples[offset++ * numFrames + currentFrame] = readInt16 (EulerHeadingLsbAddress + 24 ) * accelerationScale ;
249+ bnoSamples[offset++ * NumFrames + currentFrame] = readInt16 (EulerHeadingLsbAddress + 20 ) * AccelerationScale ;
250+ bnoSamples[offset++ * NumFrames + currentFrame] = readInt16 (EulerHeadingLsbAddress + 22 ) * AccelerationScale ;
251+ bnoSamples[offset++ * NumFrames + currentFrame] = readInt16 (EulerHeadingLsbAddress + 24 ) * AccelerationScale ;
247252
248253 // Temperature
249254
250255 oni_reg_val_t byte;
251256 ReadByte (EulerHeadingLsbAddress + 26 , &byte);
252- bnoSamples[offset++ * numFrames + currentFrame] = static_cast <uint8_t >(byte);
257+ bnoSamples[offset++ * NumFrames + currentFrame] = static_cast <uint8_t >(byte);
253258
254259 // Calibration Status
255260
256261 ReadByte (EulerHeadingLsbAddress + 27 , &byte);
257-
262+
258263 constexpr uint8_t statusMask = 0b11 ;
259264
260265 for (int i = 0 ; i < 4 ; i++)
261266 {
262- bnoSamples[currentFrame + (offset + i) * numFrames ] = (byte & (statusMask << (2 * i))) >> (2 * i);
267+ bnoSamples[currentFrame + (offset + i) * NumFrames ] = (byte & (statusMask << (2 * i))) >> (2 * i);
263268 }
264269
265270 oni_reg_val_t timestampL = 0 , timestampH = 0 ;
@@ -274,9 +279,9 @@ void PolledBno055::hiResTimerCallback()
274279
275280 currentFrame++;
276281
277- if (currentFrame >= numFrames )
282+ if (currentFrame >= NumFrames )
278283 {
279- bnoBuffer->addToBuffer (bnoSamples.data (), sampleNumbers, bnoTimestamps, eventCodes, numFrames );
284+ bnoBuffer->addToBuffer (bnoSamples.data (), sampleNumbers, bnoTimestamps, eventCodes, NumFrames );
280285 currentFrame = 0 ;
281286 }
282287}
0 commit comments