Update the Integrator class local variable dt from double to float and utilize the hrt_abstime typedef. (#12935)

This commit is contained in:
Mark Sauder
2019-09-25 06:41:54 -06:00
committed by Julian Oes
parent 0b368d043f
commit db8e203a7a
+5 -5
View File
@@ -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) {
@@ -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
@@ -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);
}