mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-17 06:17:35 +08:00
EKF: ImuDownSampler pass imuSample as const reference
- inline ImuDownSampler::getDownSampledImuAndTriggerReset() - minor formatting and initialization cleanup
This commit is contained in:
@@ -1,20 +1,15 @@
|
|||||||
#include "imu_down_sampler.hpp"
|
#include "imu_down_sampler.hpp"
|
||||||
|
|
||||||
ImuDownSampler::ImuDownSampler(float target_dt_sec) : _target_dt{target_dt_sec}, _imu_collection_time_adj{0.0f} {
|
ImuDownSampler::ImuDownSampler(float target_dt_sec) : _target_dt{target_dt_sec} { reset(); }
|
||||||
reset();
|
|
||||||
_imu_down_sampled.time_us = 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
ImuDownSampler::~ImuDownSampler() {}
|
|
||||||
|
|
||||||
// integrate imu samples until target dt reached
|
// integrate imu samples until target dt reached
|
||||||
// assumes that dt of the gyroscope is close to the dt of the accelerometer
|
// assumes that dt of the gyroscope is close to the dt of the accelerometer
|
||||||
// returns true if target dt is reached
|
// returns true if target dt is reached
|
||||||
bool ImuDownSampler::update(imuSample imu_sample_new) {
|
bool ImuDownSampler::update(const imuSample &imu_sample_new) {
|
||||||
|
|
||||||
if (_do_reset) {
|
if (_do_reset) {
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
// accumulate time deltas
|
// accumulate time deltas
|
||||||
_imu_down_sampled.delta_ang_dt += imu_sample_new.delta_ang_dt;
|
_imu_down_sampled.delta_ang_dt += imu_sample_new.delta_ang_dt;
|
||||||
_imu_down_sampled.delta_vel_dt += imu_sample_new.delta_vel_dt;
|
_imu_down_sampled.delta_vel_dt += imu_sample_new.delta_vel_dt;
|
||||||
@@ -51,11 +46,6 @@ bool ImuDownSampler::update(imuSample imu_sample_new) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
imuSample ImuDownSampler::getDownSampledImuAndTriggerReset() {
|
|
||||||
_do_reset = true;
|
|
||||||
return _imu_down_sampled;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImuDownSampler::reset() {
|
void ImuDownSampler::reset() {
|
||||||
_imu_down_sampled.delta_ang.setZero();
|
_imu_down_sampled.delta_ang.setZero();
|
||||||
_imu_down_sampled.delta_vel.setZero();
|
_imu_down_sampled.delta_vel.setZero();
|
||||||
|
|||||||
+14
-10
@@ -46,18 +46,22 @@ using namespace estimator;
|
|||||||
|
|
||||||
class ImuDownSampler {
|
class ImuDownSampler {
|
||||||
public:
|
public:
|
||||||
ImuDownSampler(float target_dt_sec);
|
explicit ImuDownSampler(float target_dt_sec);
|
||||||
~ImuDownSampler();
|
~ImuDownSampler() = default;
|
||||||
|
|
||||||
bool update(imuSample imu_sample_new);
|
bool update(const imuSample &imu_sample_new);
|
||||||
imuSample getDownSampledImuAndTriggerReset();
|
|
||||||
|
imuSample getDownSampledImuAndTriggerReset() {
|
||||||
|
_do_reset = true;
|
||||||
|
return _imu_down_sampled;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
imuSample _imu_down_sampled;
|
|
||||||
Quatf _delta_angle_accumulated;
|
|
||||||
const float _target_dt; // [sec]
|
|
||||||
float _imu_collection_time_adj;
|
|
||||||
bool _do_reset;
|
|
||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
|
imuSample _imu_down_sampled{};
|
||||||
|
Quatf _delta_angle_accumulated{};
|
||||||
|
const float _target_dt; // [sec]
|
||||||
|
float _imu_collection_time_adj{0.f};
|
||||||
|
bool _do_reset{true};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user