mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-25 09:33:34 +08:00
EKF: Use common timeout test for reporting deadreckoning
Use a parameter to set the time-out threshold Use a class variable for the time-out flag Clean up comments
This commit is contained in:
committed by
Lorenz Meier
parent
6ac7e2f807
commit
040639837e
+17
-40
@@ -741,27 +741,17 @@ void Ekf::get_ekf_gpos_accuracy(float *ekf_eph, float *ekf_epv, bool *dead_recko
|
||||
|
||||
}
|
||||
|
||||
// report dead reckoning if it is more than a second since we fused in measurements that constrain velocity drift
|
||||
uint64_t dead_reckoning_duration = math::min(math::min((_time_last_imu - _time_last_pos_fuse),(_time_last_imu - _time_last_vel_fuse)),(_time_last_imu - _time_last_of_fuse));
|
||||
bool is_dead_reckoning = dead_reckoning_duration > 1e6;
|
||||
|
||||
// If we are dead-reckoning, use the innovations as a conservative alternate measure of the horizontal velocity error
|
||||
// The reason is that complete rejection of measurements is often caused by heading misalignment or inertial sensing errors
|
||||
// If we are dead-reckoning, use the innovations as a conservative alternate measure of the horizontal position error
|
||||
// The reason is that complete rejection of measurements is often casued by heading misalignment or inertial sensing errors
|
||||
// and using state variances for accuracy reporting is overly optimistic in these situations
|
||||
float pos_err_alt = 0.0f;
|
||||
if (is_dead_reckoning) {
|
||||
// calculate a conservative estimate of the error in our position
|
||||
if (_control_status.flags.gps || _control_status.flags.ev_pos) {
|
||||
pos_err_alt = math::max(pos_err_alt, sqrtf(_vel_pos_innov[3]*_vel_pos_innov[3] + _vel_pos_innov[4]*_vel_pos_innov[4]));
|
||||
|
||||
}
|
||||
hpos_err = math::max(hpos_err, pos_err_alt);
|
||||
if (_is_dead_reckoning && (_control_status.flags.gps || _control_status.flags.ev_pos)) {
|
||||
hpos_err = math::max(hpos_err, sqrtf(_vel_pos_innov[3]*_vel_pos_innov[3] + _vel_pos_innov[4]*_vel_pos_innov[4]));
|
||||
|
||||
}
|
||||
|
||||
memcpy(ekf_eph, &hpos_err, sizeof(float));
|
||||
memcpy(ekf_epv, &vpos_err, sizeof(float));
|
||||
memcpy(dead_reckoning, &is_dead_reckoning, sizeof(bool));
|
||||
memcpy(dead_reckoning, &_is_dead_reckoning, sizeof(bool));
|
||||
}
|
||||
|
||||
// get the 1-sigma horizontal and vertical position uncertainty of the ekf local position
|
||||
@@ -781,27 +771,17 @@ void Ekf::get_ekf_lpos_accuracy(float *ekf_eph, float *ekf_epv, bool *dead_recko
|
||||
|
||||
}
|
||||
|
||||
// report dead reckoning if it is more than a second since we fused in measurements that constrain velocity drift
|
||||
uint64_t dead_reckoning_duration = math::min(math::min((_time_last_imu - _time_last_pos_fuse),(_time_last_imu - _time_last_vel_fuse)),(_time_last_imu - _time_last_of_fuse));
|
||||
bool is_dead_reckoning = dead_reckoning_duration > 1e6;
|
||||
|
||||
// If we are dead-reckoning, use the innovations as a conservative alternate measure of the horizontal velocity error
|
||||
// If we are dead-reckoning, use the innovations as a conservative alternate measure of the horizontal position error
|
||||
// The reason is that complete rejection of measurements is often casued by heading misalignment or inertial sensing errors
|
||||
// and using state variances for accuracy reporting is overly optimistic in these situations
|
||||
float pos_err_alt = 0.0f;
|
||||
if (is_dead_reckoning) {
|
||||
// calculate a conservative estimate of the error in our position
|
||||
if (_control_status.flags.gps || _control_status.flags.ev_pos) {
|
||||
pos_err_alt = math::max(pos_err_alt, sqrtf(_vel_pos_innov[3]*_vel_pos_innov[3] + _vel_pos_innov[4]*_vel_pos_innov[4]));
|
||||
|
||||
}
|
||||
hpos_err = math::max(hpos_err, pos_err_alt);
|
||||
if (_is_dead_reckoning && (_control_status.flags.gps || _control_status.flags.ev_pos)) {
|
||||
hpos_err = math::max(hpos_err, sqrtf(_vel_pos_innov[3]*_vel_pos_innov[3] + _vel_pos_innov[4]*_vel_pos_innov[4]));
|
||||
|
||||
}
|
||||
|
||||
memcpy(ekf_eph, &hpos_err, sizeof(float));
|
||||
memcpy(ekf_epv, &vpos_err, sizeof(float));
|
||||
memcpy(dead_reckoning, &is_dead_reckoning, sizeof(bool));
|
||||
memcpy(dead_reckoning, &_is_dead_reckoning, sizeof(bool));
|
||||
}
|
||||
|
||||
// get the 1-sigma horizontal and vertical velocity uncertainty
|
||||
@@ -820,27 +800,24 @@ void Ekf::get_ekf_vel_accuracy(float *ekf_evh, float *ekf_evv, bool *dead_reckon
|
||||
|
||||
}
|
||||
|
||||
// report dead reckoning if it is more than a second since we fused in measurements that constrain velocity drift
|
||||
bool is_dead_reckoning = (_time_last_imu - _time_last_pos_fuse > 1e6) && (_time_last_imu - _time_last_vel_fuse > 1e6) && (_time_last_imu - _time_last_of_fuse > 1e6);
|
||||
|
||||
// If we are dead-reckoning, use the innovations as a conservative alternate measure of the horizontal velocity error
|
||||
// The reason is that complete rejection of measurements is often be casued by heading misalignment or inertial sensing errors
|
||||
// and using state variances for accuracy reporting provides an overly optimistic assessment in these situations
|
||||
float vel_err_alt = 0.0f;
|
||||
if (is_dead_reckoning) {
|
||||
// The reason is that complete rejection of measurements is often caused by heading misalignment or inertial sensing errors
|
||||
// and using state variances for accuracy reporting is overly optimistic in these situations
|
||||
float vel_err_conservative = 0.0f;
|
||||
if (_is_dead_reckoning) {
|
||||
if (_control_status.flags.opt_flow) {
|
||||
float gndclearance = math::max(_params.rng_gnd_clearance, 0.1f);
|
||||
vel_err_alt = math::max((_terrain_vpos - _state.pos(2)), gndclearance) * sqrtf(_flow_innov[0]*_flow_innov[0] + _flow_innov[1]*_flow_innov[1]);
|
||||
vel_err_conservative = math::max((_terrain_vpos - _state.pos(2)), gndclearance) * sqrtf(_flow_innov[0]*_flow_innov[0] + _flow_innov[1]*_flow_innov[1]);
|
||||
}
|
||||
if (_control_status.flags.gps || _control_status.flags.ev_pos) {
|
||||
vel_err_alt = math::max(vel_err_alt, sqrtf(_vel_pos_innov[0]*_vel_pos_innov[0] + _vel_pos_innov[1]*_vel_pos_innov[1]));
|
||||
vel_err_conservative = math::max(vel_err_conservative, sqrtf(_vel_pos_innov[0]*_vel_pos_innov[0] + _vel_pos_innov[1]*_vel_pos_innov[1]));
|
||||
}
|
||||
hvel_err = math::max(hvel_err, vel_err_alt);
|
||||
hvel_err = math::max(hvel_err, vel_err_conservative);
|
||||
}
|
||||
|
||||
memcpy(ekf_evh, &hvel_err, sizeof(float));
|
||||
memcpy(ekf_evv, &vvel_err, sizeof(float));
|
||||
memcpy(dead_reckoning, &is_dead_reckoning, sizeof(bool));
|
||||
memcpy(dead_reckoning, &_is_dead_reckoning, sizeof(bool));
|
||||
}
|
||||
|
||||
// get EKF innovation consistency check status information comprising of:
|
||||
|
||||
Reference in New Issue
Block a user