From db8e203a7adbf0c3f7fa06a40e58cdb36387fb62 Mon Sep 17 00:00:00 2001 From: Mark Sauder Date: Wed, 25 Sep 2019 06:41:54 -0600 Subject: [PATCH] Update the Integrator class local variable dt from double to float and utilize the hrt_abstime typedef. (#12935) --- src/lib/drivers/device/integrator.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib/drivers/device/integrator.cpp b/src/lib/drivers/device/integrator.cpp index f53cc2c082..4810d60938 100644 --- a/src/lib/drivers/device/integrator.cpp +++ b/src/lib/drivers/device/integrator.cpp @@ -51,7 +51,7 @@ Integrator::Integrator(uint32_t auto_reset_interval, bool coning_compensation) : } bool -Integrator::put(const uint64_t ×tamp, const matrix::Vector3f &val, matrix::Vector3f &integral, +Integrator::put(const hrt_abstime ×tamp, const matrix::Vector3f &val, matrix::Vector3f &integral, uint32_t &integral_dt) { if (_last_integration_time == 0) { @@ -63,13 +63,13 @@ Integrator::put(const uint64_t ×tamp, const matrix::Vector3f &val, matrix:: return false; } - double dt = 0.0; + float dt = 0.0f; // Integrate: // Leave dt at 0 if the integration time does not make sense. // Without this check the integral is likely to explode. if (timestamp >= _last_integration_time) { - dt = (double)(timestamp - _last_integration_time) / 1000000.0; + dt = static_cast(timestamp - _last_integration_time) * 1e-6f; } // Use trapezoidal integration to calculate the delta integral @@ -120,7 +120,7 @@ Integrator::put_with_interval(unsigned interval_us, matrix::Vector3f &val, matri { if (_last_integration_time == 0) { /* this is the first item in the integrator */ - uint64_t now = hrt_absolute_time(); + hrt_abstime now = hrt_absolute_time(); _last_integration_time = now; _last_reset_time = now; _last_val = val; @@ -129,7 +129,7 @@ Integrator::put_with_interval(unsigned interval_us, matrix::Vector3f &val, matri } // Create the timestamp artifically. - const uint64_t timestamp = _last_integration_time + interval_us; + const hrt_abstime timestamp = _last_integration_time + interval_us; return put(timestamp, val, integral, integral_dt); }