Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
Ekf: extract baro height offset computation
Browse files Browse the repository at this point in the history
  • Loading branch information
bresch committed Apr 16, 2020
1 parent b77988e commit 9148118
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
11 changes: 1 addition & 10 deletions EKF/control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1050,16 +1050,7 @@ void Ekf::controlHeightFusion()
break;
}

// calculate a filtered offset between the baro origin and local NED origin if we are not using the baro as a height reference
if (!_control_status.flags.baro_hgt && _baro_data_ready) {
float local_time_step = 1e-6f * _delta_time_baro_us;
local_time_step = math::constrain(local_time_step, 0.0f, 1.0f);

// apply a 10 second first order low pass filter to baro offset
float offset_rate_correction = 0.1f * (_baro_sample_delayed.hgt + _state.pos(
2) - _baro_hgt_offset);
_baro_hgt_offset += local_time_step * math::constrain(offset_rate_correction, -0.1f, 0.1f);
}
updateBaroHgtOffset();

if (isTimedOut(_time_last_hgt_fuse, 2 * RNG_MAX_INTERVAL) && _control_status.flags.rng_hgt
&& (!_range_sensor.isDataHealthy())) {
Expand Down
2 changes: 2 additions & 0 deletions EKF/ekf.h
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,8 @@ class Ekf : public EstimatorInterface
void startBaroHgtFusion();
void startGpsHgtFusion();

void updateBaroHgtOffset();

// calculate the measurement variance for the optical flow sensor
float calcOptFlowMeasVar();

Expand Down
15 changes: 15 additions & 0 deletions EKF/ekf_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1498,6 +1498,21 @@ void Ekf::startGpsHgtFusion()
}
}

void Ekf::updateBaroHgtOffset()
{
// calculate a filtered offset between the baro origin and local NED origin if we are not
// using the baro as a height reference
if (!_control_status.flags.baro_hgt && _baro_data_ready) {
float local_time_step = 1e-6f * _delta_time_baro_us;
local_time_step = math::constrain(local_time_step, 0.0f, 1.0f);

// apply a 10 second first order low pass filter to baro offset
float offset_rate_correction = 0.1f * (_baro_sample_delayed.hgt + _state.pos(
2) - _baro_hgt_offset);
_baro_hgt_offset += local_time_step * math::constrain(offset_rate_correction, -0.1f, 0.1f);
}
}

// update the rotation matrix which rotates EV measurements into the EKF's navigation frame
void Ekf::calcExtVisRotMat()
{
Expand Down

0 comments on commit 9148118

Please sign in to comment.