Skip to content

Commit

Permalink
Update the Integrator class local variable dt from double to float an…
Browse files Browse the repository at this point in the history
…d utilize the hrt_abstime typedef. (#12935)
  • Loading branch information
mcsauder authored and julianoes committed Sep 25, 2019
1 parent 0b368d0 commit db8e203
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/lib/drivers/device/integrator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Integrator::Integrator(uint32_t auto_reset_interval, bool coning_compensation) :
}

bool
Integrator::put(const uint64_t &timestamp, const matrix::Vector3f &val, matrix::Vector3f &integral,
Integrator::put(const hrt_abstime &timestamp, const matrix::Vector3f &val, matrix::Vector3f &integral,
uint32_t &integral_dt)
{
if (_last_integration_time == 0) {
Expand All @@ -63,13 +63,13 @@ Integrator::put(const uint64_t &timestamp, 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<float>(timestamp - _last_integration_time) * 1e-6f;
}

// Use trapezoidal integration to calculate the delta integral
Expand Down Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down

0 comments on commit db8e203

Please sign in to comment.