Closed garlinplus closed 3 years ago
The case VDIST_SENSOR_RANGE may be modified as followed: if (_range_sensor.isDataHealthy()) { setControlRangeHeight(); fuse_height = true;
if (_control_status_prev.flags.rng_hgt != _control_status.flags.rng_hgt) {
// we have just switched to using range finder, calculate height sensor offset such that current
// measurement matches our current height estimate
// use the parameter rng_gnd_clearance if on ground to avoid a noisy offset initialization (e.g. sonar)
if (_control_status.flags.in_air && isTerrainEstimateValid()) {
_hgt_sensor_offset = _terrain_vpos;
} else if (_control_status.flags.in_air) {
_hgt_sensor_offset = _range_sensor.getDistBottom() + _state.pos(2);
} else {
_hgt_sensor_offset = _params.rng_gnd_clearance;
}
}
} else if (!_range_sensor.Healthy()&& _baro_data_ready && !_baro_hgt_faulty) {
startBaroHgtFusion();
fuse_height = true;
}
when ranger is selected as primary height sensor.EKF get time aligned ranger data from ring buffer as followed: void Ekf::controlFusionModes() { // Store the status to enable change detection _control_status_prev.value = _control_status.value;
}
As above bold code,EKF run with 8ms,And my ranger sensor with 20hz.So there may be not sensor data. But in followed function: void Ekf::controlHeightFusion() { checkRangeAidSuitability(); const bool do_range_aid = (_params.range_aid == 1) && isRangeAidSuitable();
}
In case VDIST_SENSOR_RANGE,if we do not get ranger data in ring buffer,height source will be changed from ranger fusion to baro fusion.The above changed logic is not correct. if (_range_sensor.isDataHealthy()) { setControlRangeHeight(); fuse_height = true;
The check of ranger valid check should be constraint in a time region.