Skip to content

Commit 195fd99

Browse files
committed
Use milliis instead
1 parent 3ac1267 commit 195fd99

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

src/sensors/bno080sensor.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
#define SMART_ACCEL_STABLE 0.8f
4242
#define SMART_CORRECT_TIME_MS 2000.f
4343
#define SMART_BETA 0.2f
44-
#define M2S 1.0f / 1000000.0f
44+
#define MS2S 1.0f / 1000.0f
4545
#endif
4646

4747
#define CALIB_MODE_INIT 0
@@ -133,8 +133,7 @@ void BNO080Sensor::motionLoop()
133133
//Look for reports from the IMU
134134
while (imu.dataAvailable())
135135
{
136-
unsigned long timeStamp = micros();
137-
136+
unsigned long timeStamp = millis();
138137
hadData = true;
139138

140139
#if ENABLE_INSPECTION
@@ -214,15 +213,15 @@ void BNO080Sensor::motionLoop()
214213

215214
if(last_gyro_timestamp != 0)
216215
{
217-
float gyroDelta = (timeStamp - last_gyro_timestamp) * M2S;
216+
float gyroDelta = (timeStamp - last_gyro_timestamp) * MS2S;
218217

219218
avgGxyz[0] += Gxyz[0] * gyroDelta;
220219
avgGxyz[1] += Gxyz[1] * gyroDelta;
221220
avgGxyz[2] += Gxyz[2] * gyroDelta;
222221

223-
if ((timeStamp - elapsed_gyro_time) * M2S > MADGWICK_UPDATE_RATE_MS / 1000.0f)
222+
if ((timeStamp - elapsed_gyro_time) * MS2S > MADGWICK_UPDATE_RATE_MS / 1000.0f)
224223
{
225-
float totalTime = (timeStamp - elapsed_gyro_time) * M2S;
224+
float totalTime = (timeStamp - elapsed_gyro_time) * MS2S;
226225

227226
float newGxyz[3];
228227
newGxyz[0] = avgGxyz[0] / totalTime;
@@ -443,7 +442,7 @@ void BNO080Sensor::saveCalibration()
443442

444443
#if BNO_USE_MADGWICK
445444
void BNO080Sensor::doMadgwickUpdate(float Axyz[3], float Gxyz[3], float Mxyz[3], float timestamp) {
446-
float lastDelta = (timestamp - lastMadgwick) * M2S;
445+
float lastDelta = (timestamp - lastMadgwick) * MS2S;
447446
lastMadgwick = timestamp;
448447

449448
//m_Logger.debug("lastDelta : %f", lastDelta);

0 commit comments

Comments
 (0)