mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-31 04:51:35 +08:00
Update the Integrator class local variable dt from double to float and utilize the hrt_abstime typedef. (#12935)
This commit is contained in:
@@ -51,7 +51,7 @@ Integrator::Integrator(uint32_t auto_reset_interval, bool coning_compensation) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
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)
|
uint32_t &integral_dt)
|
||||||
{
|
{
|
||||||
if (_last_integration_time == 0) {
|
if (_last_integration_time == 0) {
|
||||||
@@ -63,13 +63,13 @@ Integrator::put(const uint64_t ×tamp, const matrix::Vector3f &val, matrix::
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
double dt = 0.0;
|
float dt = 0.0f;
|
||||||
|
|
||||||
// Integrate:
|
// Integrate:
|
||||||
// Leave dt at 0 if the integration time does not make sense.
|
// Leave dt at 0 if the integration time does not make sense.
|
||||||
// Without this check the integral is likely to explode.
|
// Without this check the integral is likely to explode.
|
||||||
if (timestamp >= _last_integration_time) {
|
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
|
// 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) {
|
if (_last_integration_time == 0) {
|
||||||
/* this is the first item in the integrator */
|
/* 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_integration_time = now;
|
||||||
_last_reset_time = now;
|
_last_reset_time = now;
|
||||||
_last_val = val;
|
_last_val = val;
|
||||||
@@ -129,7 +129,7 @@ Integrator::put_with_interval(unsigned interval_us, matrix::Vector3f &val, matri
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create the timestamp artifically.
|
// 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);
|
return put(timestamp, val, integral, integral_dt);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user