ekf: Extract resetState from main reset and reinitialize

the covariances in the init function
This commit is contained in:
bresch
2019-11-05 09:07:25 +01:00
committed by Mathieu Bresciani
parent bf48004fb9
commit a6840655e8
3 changed files with 30 additions and 14 deletions
+25 -14
View File
@@ -54,20 +54,7 @@ bool Ekf::init(uint64_t timestamp)
void Ekf::reset(uint64_t timestamp) void Ekf::reset(uint64_t timestamp)
{ {
_state.vel.setZero(); resetStatesAndCovariances();
_state.pos.setZero();
_state.gyro_bias.setZero();
_state.accel_bias.setZero();
_state.mag_I.setZero();
_state.mag_B.setZero();
_state.wind_vel.setZero();
_state.quat_nominal.setZero();
_state.quat_nominal(0) = 1.0f;
_output_new.vel.setZero();
_output_new.pos.setZero();
_output_new.quat_nominal.setZero();
_output_new.quat_nominal(0) = 1.0f;
_delta_angle_corr.setZero(); _delta_angle_corr.setZero();
_imu_down_sampled.delta_ang.setZero(); _imu_down_sampled.delta_ang.setZero();
@@ -103,6 +90,30 @@ void Ekf::reset(uint64_t timestamp)
_prev_dvel_bias_var.zero(); _prev_dvel_bias_var.zero();
} }
void Ekf::resetStatesAndCovariances()
{
resetStates();
initialiseCovariance();
}
void Ekf::resetStates()
{
_state.vel.setZero();
_state.pos.setZero();
_state.gyro_bias.setZero();
_state.accel_bias.setZero();
_state.mag_I.setZero();
_state.mag_B.setZero();
_state.wind_vel.setZero();
_state.quat_nominal.setZero();
_state.quat_nominal(0) = 1.0f;
_output_new.vel.setZero();
_output_new.pos.setZero();
_output_new.quat_nominal.setZero();
_output_new.quat_nominal(0) = 1.0f;
}
bool Ekf::update() bool Ekf::update()
{ {
bool updated = false; bool updated = false;
+3
View File
@@ -57,6 +57,9 @@ public:
// set the internal states and status to their default value // set the internal states and status to their default value
void reset(uint64_t timestamp) override; void reset(uint64_t timestamp) override;
void resetStatesAndCovariances() override;
void resetStates() override;
// should be called every time new data is pushed into the filter // should be called every time new data is pushed into the filter
bool update() override; bool update() override;
+2
View File
@@ -60,6 +60,8 @@ public:
virtual bool init(uint64_t timestamp) = 0; virtual bool init(uint64_t timestamp) = 0;
virtual void reset(uint64_t timestamp) = 0; virtual void reset(uint64_t timestamp) = 0;
virtual void resetStates() = 0;
virtual void resetStatesAndCovariances() = 0;
virtual bool update() = 0; virtual bool update() = 0;
// gets the innovations of velocity and position measurements // gets the innovations of velocity and position measurements