Skip to content

Commit

Permalink
ekf2: don't fuse optical flow samples when the current distance to th…
Browse files Browse the repository at this point in the history
…e ground is larger than the reported maximum flow sensor distance

Signed-off-by: RomanBapst <[email protected]>
  • Loading branch information
RomanBapst authored Jun 12, 2024
1 parent 5dd7633 commit 0ce64e1
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,13 @@ void Ekf::controlOpticalFlowFusion(const imuSample &imu_delayed)
&& !_flow_sample_delayed.flow_rate.longerThan(_flow_max_rate);
const bool is_tilt_good = (_R_to_earth(2, 2) > _params.range_cos_max_tilt);

// don't enforce this condition if terrain estimate is not valid as we have logic below to coast through bad range finder data
const bool is_within_max_sensor_dist = isTerrainEstimateValid() ? (_terrain_vpos - _state.pos(2) <= _flow_max_distance) : true;

if (is_quality_good
&& is_magnitude_good
&& is_tilt_good) {
&& is_tilt_good
&& is_within_max_sensor_dist) {
// compensate for body motion to give a LOS rate
calcOptFlowBodyRateComp(imu_delayed);
_flow_rate_compensated = _flow_sample_delayed.flow_rate - _flow_sample_delayed.gyro_rate.xy();
Expand Down

0 comments on commit 0ce64e1

Please sign in to comment.