mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-12-02 22:40:27 +08:00
feat(ekf2): make sequential fusion order-invariant (NASA Whitepaper 2025 Algorithm 4.1)
This commit is contained in:
1 parent
b534b2a0b0
commit
a3f3b861e3
12 files changed
+108
-55
No files matched your search
@@ -64,12 +64,16 @@ bool ZeroGyroUpdate::update(Ekf &ekf, const estimator::imuSample &imu_delayed)
|
||||
|
||||
const float obs_var = sq(math::constrain(ekf.getGyroNoise(), 0.f, 1.f));
|
||||
|
||||
Ekf::VectorState state_correction;
|
||||
|
||||
for (unsigned i = 0; i < 3; i++) {
|
||||
const float innovation = ekf.state().gyro_bias(i) - gyro_bias(i);
|
||||
const float innov_var = ekf.getGyroBiasVariance()(i) + obs_var;
|
||||
ekf.fuseDirectStateMeasurement(innovation, innov_var, obs_var, State::gyro_bias.idx + i);
|
||||
ekf.fuseDirectStateMeasurement(innovation, innov_var, obs_var, State::gyro_bias.idx + i, state_correction);
|
||||
}
|
||||
|
||||
ekf.applyStateCorrection(state_correction);
|
||||
|
||||
// Reset the integrators
|
||||
_zgup_delta_ang.setZero();
|
||||
_zgup_delta_ang_dt = 0.f;
|
||||
|
||||
@@ -63,13 +63,16 @@ bool ZeroVelocityUpdate::update(Ekf &ekf, const estimator::imuSample &imu_delaye
|
||||
// later to let the states follow the measurements
|
||||
const float obs_var = ekf.control_status_flags().tilt_align ? sq(0.2f) : sq(0.001f);
|
||||
|
||||
Ekf::VectorState state_correction;
|
||||
|
||||
for (unsigned i = 0; i < 3; i++) {
|
||||
// recalculate using the updated state and variance
|
||||
const float innovation = ekf.state().vel(i) - vel_obs(i);
|
||||
const float innov_var = ekf.getVelocityVariance()(i) + obs_var;
|
||||
ekf.fuseDirectStateMeasurement(innovation, innov_var, obs_var, State::vel.idx + i);
|
||||
ekf.fuseDirectStateMeasurement(innovation, innov_var, obs_var, State::vel.idx + i, state_correction);
|
||||
}
|
||||
|
||||
ekf.applyStateCorrection(state_correction);
|
||||
|
||||
_time_last_fuse = imu_delayed.time_us;
|
||||
|
||||
return true;
|
||||
|
||||
@@ -92,8 +92,9 @@ void Ekf::fuseDrag(const dragSample &drag_sample)
|
||||
return;
|
||||
}
|
||||
|
||||
const Vector3f rel_wind_body_prev = getRelativeWindBody();
|
||||
const auto state_vector_prev = _state.vector();
|
||||
const Vector3f rel_wind_body = getRelativeWindBody();
|
||||
const float rel_wind_speed = rel_wind_body.norm();
|
||||
const auto state_vector = _state.vector();
|
||||
|
||||
Vector2f bcoef_inv{0.f, 0.f};
|
||||
|
||||
@@ -109,8 +110,7 @@ void Ekf::fuseDrag(const dragSample &drag_sample)
|
||||
|
||||
// Interpolate between the X and Y bluff body drag coefficients using current relative velocity
|
||||
// This creates an elliptic drag distribution around the XY plane
|
||||
// this is part of the drag model, so it must stay frozen at the linearisation point used for H
|
||||
bcoef_inv(0) = Vector2f(bcoef_inv.emult(rel_wind_body_prev.xy()) / rel_wind_body_prev.xy().norm()).norm();
|
||||
bcoef_inv(0) = Vector2f(bcoef_inv.emult(rel_wind_body.xy()) / rel_wind_body.xy().norm()).norm();
|
||||
bcoef_inv(1) = bcoef_inv(0);
|
||||
}
|
||||
|
||||
@@ -123,13 +123,10 @@ void Ekf::fuseDrag(const dragSample &drag_sample)
|
||||
const float innov_gate = 5.f;
|
||||
|
||||
VectorState H;
|
||||
VectorState state_correction;
|
||||
|
||||
// perform sequential fusion of XY specific forces
|
||||
for (uint8_t axis_index = 0; axis_index < 2; axis_index++) {
|
||||
// recalculate innovation using the updated state
|
||||
const Vector3f rel_wind_body = getRelativeWindBody();
|
||||
const float rel_wind_speed = rel_wind_body.norm();
|
||||
|
||||
// measured drag acceleration corrected for sensor bias
|
||||
const float mea_acc = drag_sample.accelXY(axis_index) - _state.accel_bias(axis_index);
|
||||
|
||||
@@ -143,7 +140,7 @@ void Ekf::fuseDrag(const dragSample &drag_sample)
|
||||
innovation(axis_index) = pred_acc - mea_acc;
|
||||
|
||||
if (axis_index == 0) {
|
||||
sym::ComputeDragXInnovVarAndH(state_vector_prev, P, rho, bcoef_inv(axis_index), mcoef_corrrected, R_ACC, FLT_EPSILON,
|
||||
sym::ComputeDragXInnovVarAndH(state_vector, P, rho, bcoef_inv(axis_index), mcoef_corrrected, R_ACC, FLT_EPSILON,
|
||||
&innovation_variance(axis_index), &H);
|
||||
|
||||
if (!using_bcoef_x && !using_mcoef) {
|
||||
@@ -151,7 +148,7 @@ void Ekf::fuseDrag(const dragSample &drag_sample)
|
||||
}
|
||||
|
||||
} else if (axis_index == 1) {
|
||||
sym::ComputeDragYInnovVarAndH(state_vector_prev, P, rho, bcoef_inv(axis_index), mcoef_corrrected, R_ACC, FLT_EPSILON,
|
||||
sym::ComputeDragYInnovVarAndH(state_vector, P, rho, bcoef_inv(axis_index), mcoef_corrrected, R_ACC, FLT_EPSILON,
|
||||
&innovation_variance(axis_index), &H);
|
||||
|
||||
if (!using_bcoef_y && !using_mcoef) {
|
||||
@@ -173,10 +170,12 @@ void Ekf::fuseDrag(const dragSample &drag_sample)
|
||||
|
||||
VectorState K = computeKalmanGain(H, innovation_variance(axis_index));
|
||||
|
||||
measurementUpdate(K, H, R_ACC, innovation(axis_index));
|
||||
measurementUpdate(K, H, R_ACC, innovation(axis_index), state_correction);
|
||||
}
|
||||
}
|
||||
|
||||
applyStateCorrection(state_correction);
|
||||
|
||||
updateAidSourceStatus(_aid_src_drag,
|
||||
drag_sample.time_us, // sample timestamp
|
||||
observation, // observation
|
||||
|
||||
@@ -183,6 +183,8 @@ void Ekf::fuseBodyFrameVelocity(estimator_aid_source3d_s &aid_src, const uint64_
|
||||
innovation_gate); // innovation gate
|
||||
|
||||
if (!aid_src.innovation_rejected) {
|
||||
VectorState state_correction;
|
||||
|
||||
for (uint8_t index = 0; index <= 2; index++) {
|
||||
if (index == 1) {
|
||||
sym::ComputeBodyVelYInnovVar(state_vector, P, measurement_var(index), &aid_src.innovation_variance[index]);
|
||||
@@ -191,12 +193,13 @@ void Ekf::fuseBodyFrameVelocity(estimator_aid_source3d_s &aid_src, const uint64_
|
||||
sym::ComputeBodyVelZInnovVar(state_vector, P, measurement_var(index), &aid_src.innovation_variance[index]);
|
||||
}
|
||||
|
||||
aid_src.innovation[index] = Vector3f(_R_to_earth.transpose().row(index)) * _state.vel - measurement(index);
|
||||
|
||||
VectorState Kfusion = computeKalmanGain(H[index], aid_src.innovation_variance[index]);
|
||||
measurementUpdate(Kfusion, H[index], aid_src.observation_variance[index], aid_src.innovation[index]);
|
||||
measurementUpdate(Kfusion, H[index], aid_src.observation_variance[index], aid_src.innovation[index],
|
||||
state_correction);
|
||||
}
|
||||
|
||||
applyStateCorrection(state_correction);
|
||||
|
||||
aid_src.fused = true;
|
||||
aid_src.time_last_fuse = _time_delayed_us;
|
||||
|
||||
|
||||
@@ -82,6 +82,7 @@ void Ekf::controlGravityFusion(const imuSample &imu)
|
||||
|
||||
// update the states and covariance using sequential fusion
|
||||
bool fused[3] {};
|
||||
VectorState state_correction;
|
||||
|
||||
for (uint8_t index = 0; index <= 2; index++) {
|
||||
// Calculate Kalman gains and observation jacobians
|
||||
@@ -92,17 +93,9 @@ void Ekf::controlGravityFusion(const imuSample &imu)
|
||||
// recalculate innovation variance because state covariances have changed due to previous fusion (linearise using the same initial state for all axes)
|
||||
sym::ComputeGravityYInnovVarAndH(state_vector, P, measurement_var, &_aid_src_gravity.innovation_variance[index], &H);
|
||||
|
||||
// recalculate innovation using the updated state
|
||||
_aid_src_gravity.innovation[index] = _state.quat_nominal.rotateVectorInverse(Vector3f(0.f, 0.f,
|
||||
-1.f))(index) - measurement(index);
|
||||
|
||||
} else if (index == 2) {
|
||||
// recalculate innovation variance because state covariances have changed due to previous fusion (linearise using the same initial state for all axes)
|
||||
sym::ComputeGravityZInnovVarAndH(state_vector, P, measurement_var, &_aid_src_gravity.innovation_variance[index], &H);
|
||||
|
||||
// recalculate innovation using the updated state
|
||||
_aid_src_gravity.innovation[index] = _state.quat_nominal.rotateVectorInverse(Vector3f(0.f, 0.f,
|
||||
-1.f))(index) - measurement(index);
|
||||
}
|
||||
|
||||
const bool accel_clipping = imu.delta_vel_clipping[0] || imu.delta_vel_clipping[1] || imu.delta_vel_clipping[2];
|
||||
@@ -110,12 +103,14 @@ void Ekf::controlGravityFusion(const imuSample &imu)
|
||||
if (_control_status.flags.gravity_vector && !_aid_src_gravity.innovation_rejected && !accel_clipping) {
|
||||
VectorState K = computeKalmanGain(H, _aid_src_gravity.innovation_variance[index]);
|
||||
|
||||
fused[index] = measurementUpdate(K, H,
|
||||
_aid_src_gravity.observation_variance[index], _aid_src_gravity.innovation[index]);
|
||||
fused[index] = measurementUpdate(K, H, _aid_src_gravity.observation_variance[index],
|
||||
_aid_src_gravity.innovation[index], state_correction);
|
||||
}
|
||||
}
|
||||
|
||||
if (fused[0] && fused[1] && fused[2]) {
|
||||
applyStateCorrection(state_correction);
|
||||
|
||||
_aid_src_gravity.fused = true;
|
||||
_aid_src_gravity.time_last_fuse = imu.time_us;
|
||||
|
||||
|
||||
@@ -240,7 +240,7 @@ void Ekf::controlMagFusion(const imuSample &imu_sample)
|
||||
// declination angle over time.
|
||||
const bool update_all_states = _control_status.flags.mag_3D || _control_status.flags.mag_hdg;
|
||||
const bool update_tilt = _control_status.flags.mag_3D;
|
||||
fuseMag(mag_sample.mag, R_MAG, H, aid_src, update_all_states, update_tilt);
|
||||
fuseMag(R_MAG, H, aid_src, update_all_states, update_tilt);
|
||||
|
||||
// the innovation variance contribution from the state covariances is negative which means the covariance matrix is badly conditioned
|
||||
if (update_all_states && update_tilt) {
|
||||
@@ -321,7 +321,7 @@ void Ekf::controlMagFusion(const imuSample &imu_sample)
|
||||
_control_status.flags.mag = true;
|
||||
|
||||
} else {
|
||||
if (fuseMag(mag_sample.mag, R_MAG, H, aid_src)) {
|
||||
if (fuseMag(R_MAG, H, aid_src)) {
|
||||
ECL_INFO("starting %s fusion", AID_SRC_NAME);
|
||||
_control_status.flags.mag = true;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
|
||||
#include <mathlib/mathlib.h>
|
||||
|
||||
bool Ekf::fuseMag(const Vector3f &mag, const float R_MAG, VectorState &H, estimator_aid_source3d_s &aid_src,
|
||||
bool Ekf::fuseMag(const float R_MAG, VectorState &H, estimator_aid_source3d_s &aid_src,
|
||||
bool update_all_states, bool update_tilt)
|
||||
{
|
||||
// if any axis failed, abort the mag fusion
|
||||
@@ -65,6 +65,8 @@ bool Ekf::fuseMag(const Vector3f &mag, const float R_MAG, VectorState &H, estima
|
||||
: 0.f;
|
||||
float delta_heading_max = math::radians(1.f) * dt_heading;
|
||||
|
||||
VectorState state_correction;
|
||||
|
||||
// update the states and covariance using sequential fusion of the magnetometer components
|
||||
for (uint8_t index = 0; index <= 2; index++) {
|
||||
// Calculate Kalman gains and observation jacobians
|
||||
@@ -75,10 +77,6 @@ bool Ekf::fuseMag(const Vector3f &mag, const float R_MAG, VectorState &H, estima
|
||||
// recalculate innovation variance because state covariances have changed due to previous fusion (linearise using the same initial state for all axes)
|
||||
sym::ComputeMagYInnovVarAndH(state_vector, P, R_MAG, FLT_EPSILON, &aid_src.innovation_variance[index], &H);
|
||||
|
||||
// recalculate innovation using the updated state
|
||||
aid_src.innovation[index] = _state.quat_nominal.rotateVectorInverse(_state.mag_I)(index) + _state.mag_B(index) - mag(
|
||||
index);
|
||||
|
||||
} else if (index == 2) {
|
||||
// we do not fuse synthesized magnetomter measurements when doing 3D fusion
|
||||
if (_control_status.flags.synthetic_mag_z) {
|
||||
@@ -87,10 +85,6 @@ bool Ekf::fuseMag(const Vector3f &mag, const float R_MAG, VectorState &H, estima
|
||||
|
||||
// recalculate innovation variance because state covariances have changed due to previous fusion (linearise using the same initial state for all axes)
|
||||
sym::ComputeMagZInnovVarAndH(state_vector, P, R_MAG, FLT_EPSILON, &aid_src.innovation_variance[index], &H);
|
||||
|
||||
// recalculate innovation using the updated state
|
||||
aid_src.innovation[index] = _state.quat_nominal.rotateVectorInverse(_state.mag_I)(index) + _state.mag_B(index) - mag(
|
||||
index);
|
||||
}
|
||||
|
||||
if (aid_src.innovation_variance[index] < R_MAG) {
|
||||
@@ -144,9 +138,11 @@ bool Ekf::fuseMag(const Vector3f &mag, const float R_MAG, VectorState &H, estima
|
||||
delta_heading_max -= delta_heading_abs;
|
||||
}
|
||||
|
||||
measurementUpdate(Kfusion, H, aid_src.observation_variance[index], aid_src.innovation[index]);
|
||||
measurementUpdate(Kfusion, H, aid_src.observation_variance[index], aid_src.innovation[index], state_correction);
|
||||
}
|
||||
|
||||
applyStateCorrection(state_correction);
|
||||
|
||||
_fault_status.flags.bad_mag_x = false;
|
||||
_fault_status.flags.bad_mag_y = false;
|
||||
_fault_status.flags.bad_mag_z = false;
|
||||
|
||||
@@ -51,6 +51,8 @@ bool Ekf::fuseOptFlow(VectorState &H, const bool update_terrain)
|
||||
return false;
|
||||
}
|
||||
|
||||
VectorState state_correction;
|
||||
|
||||
// fuse observation axes sequentially
|
||||
for (uint8_t index = 0; index <= 1; index++) {
|
||||
if (index == 0) {
|
||||
@@ -62,11 +64,6 @@ bool Ekf::fuseOptFlow(VectorState &H, const bool update_terrain)
|
||||
const float epsilon = 1e-3f;
|
||||
sym::ComputeFlowYInnovVarAndH(state_vector, P, R_LOS, epsilon, &_aid_src_optical_flow.innovation_variance[1], &H);
|
||||
|
||||
// recalculate the innovation using the updated state
|
||||
const Vector3f flow_gyro_corrected = _flow_sample_delayed.gyro_rate - _flow_gyro_bias;
|
||||
_aid_src_optical_flow.innovation[1] = predictFlow(flow_gyro_corrected)(1) - static_cast<float>
|
||||
(_aid_src_optical_flow.observation[1]);
|
||||
|
||||
// recalculate the test ratio as the measurement jacobian is highly non linear
|
||||
// when close to the ground (singularity at 0) and the innovation can suddenly become really
|
||||
// large and destabilize the filter
|
||||
@@ -92,9 +89,11 @@ bool Ekf::fuseOptFlow(VectorState &H, const bool update_terrain)
|
||||
}
|
||||
|
||||
measurementUpdate(Kfusion, H, _aid_src_optical_flow.observation_variance[index],
|
||||
_aid_src_optical_flow.innovation[index]);
|
||||
_aid_src_optical_flow.innovation[index], state_correction);
|
||||
}
|
||||
|
||||
applyStateCorrection(state_correction);
|
||||
|
||||
_fault_status.flags.bad_optflow_X = false;
|
||||
_fault_status.flags.bad_optflow_Y = false;
|
||||
|
||||
|
||||
@@ -284,11 +284,26 @@ public:
|
||||
void fuseDirectStateMeasurement(const float innov, const float innov_var, const float R, const int state_index,
|
||||
bool constrain_variances = true);
|
||||
|
||||
// Sequential fusion of one scalar of a vector observation: innov is the innovation at the a priori
|
||||
// state and is corrected here for the state correction accumulated so far; the correction of this
|
||||
// scalar is accumulated into state_correction instead of being applied, so that the result does not
|
||||
// depend on the order the scalars are fused in. Apply the accumulated correction once with
|
||||
// applyStateCorrection() after the last scalar.
|
||||
void fuseDirectStateMeasurement(const float innov, const float innov_var, const float R, const int state_index,
|
||||
VectorState &state_correction, bool constrain_variances = true);
|
||||
|
||||
// Kalman gain P * H / innov_var for a scalar observation with Jacobian H
|
||||
VectorState computeKalmanGain(const VectorState &H, const float innov_var) const;
|
||||
|
||||
bool measurementUpdate(VectorState &K, const VectorState &H, const float R, const float innovation);
|
||||
|
||||
// sequential fusion of one scalar of a vector observation, see fuseDirectStateMeasurement
|
||||
bool measurementUpdate(VectorState &K, const VectorState &H, const float R, const float innovation,
|
||||
VectorState &state_correction);
|
||||
|
||||
// apply the state correction accumulated over the scalars of a vector observation
|
||||
void applyStateCorrection(const VectorState &state_correction);
|
||||
|
||||
// gyro bias
|
||||
const Vector3f &getGyroBias() const { return _state.gyro_bias; } // get the gyroscope bias in rad/s
|
||||
Vector3f getGyroBiasVariance() const { return getStateVariance<State::gyro_bias>(); } // get the gyroscope bias variance in rad/s
|
||||
@@ -729,7 +744,7 @@ private:
|
||||
|
||||
#if defined(CONFIG_EKF2_MAGNETOMETER)
|
||||
// ekf sequential fusion of magnetometer measurements
|
||||
bool fuseMag(const Vector3f &mag, const float R_MAG, VectorState &H, estimator_aid_source3d_s &aid_src,
|
||||
bool fuseMag(const float R_MAG, VectorState &H, estimator_aid_source3d_s &aid_src,
|
||||
bool update_all_states = false, bool update_tilt = false);
|
||||
|
||||
// fuse magnetometer declination measurement
|
||||
|
||||
@@ -1075,7 +1075,7 @@ void Ekf::updateIMUBiasInhibit(const imuSample &imu_delayed)
|
||||
}
|
||||
|
||||
void Ekf::fuseDirectStateMeasurement(const float innov, const float innov_var, const float R, const int state_index,
|
||||
bool constrain_variances)
|
||||
VectorState &state_correction, bool constrain_variances)
|
||||
{
|
||||
VectorState K; // Kalman gain vector for any single observation - sequential fusion is used.
|
||||
|
||||
@@ -1131,8 +1131,18 @@ void Ekf::fuseDirectStateMeasurement(const float innov, const float innov_var, c
|
||||
constrainStateVariances();
|
||||
}
|
||||
|
||||
// apply the state corrections
|
||||
fuse(K, innov);
|
||||
// correct the a priori innovation for the accumulated state correction, then accumulate the
|
||||
// correction of this measurement instead of applying it
|
||||
const float innov_corrected = innov + state_correction(state_index);
|
||||
state_correction -= K * innov_corrected;
|
||||
}
|
||||
|
||||
void Ekf::fuseDirectStateMeasurement(const float innov, const float innov_var, const float R, const int state_index,
|
||||
bool constrain_variances)
|
||||
{
|
||||
VectorState state_correction;
|
||||
fuseDirectStateMeasurement(innov, innov_var, R, state_index, state_correction, constrain_variances);
|
||||
applyStateCorrection(state_correction);
|
||||
}
|
||||
|
||||
Ekf::VectorState Ekf::computeKalmanGain(const VectorState &H, const float innov_var) const
|
||||
@@ -1141,7 +1151,8 @@ Ekf::VectorState Ekf::computeKalmanGain(const VectorState &H, const float innov_
|
||||
return multiplySparse(P, H, NonZeroIndices(H)) / innov_var;
|
||||
}
|
||||
|
||||
bool Ekf::measurementUpdate(VectorState &K, const VectorState &H, const float R, const float innovation)
|
||||
bool Ekf::measurementUpdate(VectorState &K, const VectorState &H, const float R, const float innovation,
|
||||
VectorState &state_correction)
|
||||
{
|
||||
clearInhibitedStateKalmanGains(K);
|
||||
|
||||
@@ -1195,11 +1206,27 @@ bool Ekf::measurementUpdate(VectorState &K, const VectorState &H, const float R,
|
||||
|
||||
constrainStateVariances();
|
||||
|
||||
// apply the state corrections
|
||||
fuse(K, innovation);
|
||||
// correct the a priori innovation for the accumulated state correction, then accumulate the
|
||||
// correction of this measurement instead of applying it
|
||||
const float innov_corrected = innovation + H.dot(state_correction);
|
||||
state_correction -= K * innov_corrected;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Ekf::measurementUpdate(VectorState &K, const VectorState &H, const float R, const float innovation)
|
||||
{
|
||||
VectorState state_correction;
|
||||
measurementUpdate(K, H, R, innovation, state_correction);
|
||||
applyStateCorrection(state_correction);
|
||||
return true;
|
||||
}
|
||||
|
||||
void Ekf::applyStateCorrection(const VectorState &correction)
|
||||
{
|
||||
// fuse() applies -K * innovation as the correction
|
||||
fuse(correction, -1.f);
|
||||
}
|
||||
|
||||
void Ekf::resetAidSourceStatusZeroInnovation(estimator_aid_source1d_s &status) const
|
||||
{
|
||||
status.time_last_fuse = _time_delayed_us;
|
||||
|
||||
@@ -59,6 +59,8 @@ bool Ekf::fuseHorizontalPositionCore(estimator_aid_source2d_s &aid_src)
|
||||
|
||||
// x & y
|
||||
if (!aid_src.innovation_rejected) {
|
||||
VectorState state_correction;
|
||||
|
||||
for (unsigned i = 0; i < 2; i++) {
|
||||
// recompute from the current state; another measurement fused earlier in this
|
||||
// update can have moved the position through the state cross-covariances
|
||||
@@ -66,9 +68,11 @@ bool Ekf::fuseHorizontalPositionCore(estimator_aid_source2d_s &aid_src)
|
||||
aid_src.innovation_variance[i] = P(State::pos.idx + i, State::pos.idx + i) + aid_src.observation_variance[i];
|
||||
|
||||
fuseDirectStateMeasurement(aid_src.innovation[i], aid_src.innovation_variance[i],
|
||||
aid_src.observation_variance[i], State::pos.idx + i);
|
||||
aid_src.observation_variance[i], State::pos.idx + i, state_correction);
|
||||
}
|
||||
|
||||
applyStateCorrection(state_correction);
|
||||
|
||||
aid_src.fused = true;
|
||||
aid_src.time_last_fuse = _time_delayed_us;
|
||||
|
||||
|
||||
@@ -37,6 +37,8 @@ bool Ekf::fuseHorizontalVelocity(estimator_aid_source2d_s &aid_src)
|
||||
{
|
||||
// vx, vy
|
||||
if (!aid_src.innovation_rejected) {
|
||||
VectorState state_correction;
|
||||
|
||||
for (unsigned i = 0; i < 2; i++) {
|
||||
// recompute from the current state; another measurement fused earlier in this
|
||||
// update can have moved the velocity through the state cross-covariances
|
||||
@@ -44,9 +46,11 @@ bool Ekf::fuseHorizontalVelocity(estimator_aid_source2d_s &aid_src)
|
||||
aid_src.innovation_variance[i] = P(State::vel.idx + i, State::vel.idx + i) + aid_src.observation_variance[i];
|
||||
|
||||
fuseDirectStateMeasurement(aid_src.innovation[i], aid_src.innovation_variance[i],
|
||||
aid_src.observation_variance[i], State::vel.idx + i);
|
||||
aid_src.observation_variance[i], State::vel.idx + i, state_correction);
|
||||
}
|
||||
|
||||
applyStateCorrection(state_correction);
|
||||
|
||||
aid_src.fused = true;
|
||||
aid_src.time_last_fuse = _time_delayed_us;
|
||||
|
||||
@@ -63,6 +67,8 @@ bool Ekf::fuseVelocity(estimator_aid_source3d_s &aid_src)
|
||||
{
|
||||
// vx, vy, vz
|
||||
if (!aid_src.innovation_rejected) {
|
||||
VectorState state_correction;
|
||||
|
||||
for (unsigned i = 0; i < 3; i++) {
|
||||
// recompute from the current state; another measurement fused earlier in this
|
||||
// update can have moved the velocity through the state cross-covariances
|
||||
@@ -70,9 +76,11 @@ bool Ekf::fuseVelocity(estimator_aid_source3d_s &aid_src)
|
||||
aid_src.innovation_variance[i] = P(State::vel.idx + i, State::vel.idx + i) + aid_src.observation_variance[i];
|
||||
|
||||
fuseDirectStateMeasurement(aid_src.innovation[i], aid_src.innovation_variance[i],
|
||||
aid_src.observation_variance[i], State::vel.idx + i);
|
||||
aid_src.observation_variance[i], State::vel.idx + i, state_correction);
|
||||
}
|
||||
|
||||
applyStateCorrection(state_correction);
|
||||
|
||||
aid_src.fused = true;
|
||||
aid_src.time_last_fuse = _time_delayed_us;
|
||||
|
||||
|
||||
Reference in new issue
Block a user