mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-04 07:00:35 +08:00
integrator: add a put method for known intervals
This adds a second put method to the integrator class. This allows to integrate with known intervals between samples, rather than based on timestamps. This makes integrating the samples coming out of the MPU9250 FIFO buffer easier.
This commit is contained in:
@@ -111,6 +111,26 @@ Integrator::put(uint64_t timestamp, math::Vector<3> &val, math::Vector<3> &integ
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
Integrator::put_with_interval(unsigned interval_us, math::Vector<3> &val, math::Vector<3> &integral,
|
||||
uint64_t &integral_dt)
|
||||
{
|
||||
if (_last_integration_time == 0) {
|
||||
/* this is the first item in the integrator */
|
||||
uint64_t now = hrt_absolute_time();
|
||||
_last_integration_time = now;
|
||||
_last_reset_time = now;
|
||||
_last_val = val;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create the timestamp artifically.
|
||||
uint64_t timestamp = _last_integration_time + interval_us;
|
||||
|
||||
return put(timestamp, val, integral, integral_dt);
|
||||
}
|
||||
|
||||
math::Vector<3>
|
||||
Integrator::get(bool reset, uint64_t &integral_dt)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user