Skip to content

Commit

Permalink
EKF: Don't reject saturated flow data when it is the only aiding source
Browse files Browse the repository at this point in the history
  • Loading branch information
priseborough committed May 9, 2018
1 parent bf902e5 commit 6cadc92
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions EKF/estimator_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,20 +364,24 @@ void EstimatorInterface::setOpticalFlowData(uint64_t time_usec, flow_message *fl


// check magnitude is within sensor limits
// use this to prevent use of a saturated flow sensor when there are other aiding sources available
float flow_rate_magnitude;
bool flow_magnitude_good = true;

if (delta_time_good) {
flow_rate_magnitude = flow->flowdata.norm() / delta_time;
flow_magnitude_good = (flow_rate_magnitude <= _params.flow_rate_max);
}

bool relying_on_flow = _control_status.flags.opt_flow
&& !_control_status.flags.gps
&& !_control_status.flags.ev_pos;

// check quality metric
bool flow_quality_good = (flow->quality >= _params.flow_qual_min);

// Always use data when on ground to allow for bad quality due to unfocussed sensors and operator handling
// If flow quality fails checks on ground, assume zero flow rate after body rate compensation
if ((delta_time_good && flow_quality_good && flow_magnitude_good) || !_control_status.flags.in_air) {
if ((delta_time_good && flow_quality_good && (flow_magnitude_good || relying_on_flow)) || !_control_status.flags.in_air) {
flowSample optflow_sample_new;
// calculate the system time-stamp for the mid point of the integration period
optflow_sample_new.time_us = time_usec - _params.flow_delay_ms * 1000 - flow->dt / 2;
Expand Down

0 comments on commit 6cadc92

Please sign in to comment.