mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-01 11:31:35 +08:00
ekf2: fix optical flow start logic
- remove fallthrough that enables flow regardless of success - add appropriate start messages for each case
This commit is contained in:
@@ -126,8 +126,6 @@ void Ekf::controlOpticalFlowFusion(const imuSample &imu_delayed)
|
|||||||
|
|
||||||
void Ekf::startFlowFusion()
|
void Ekf::startFlowFusion()
|
||||||
{
|
{
|
||||||
ECL_INFO("starting optical flow fusion");
|
|
||||||
|
|
||||||
if (_height_sensor_ref != HeightSensor::RANGE) {
|
if (_height_sensor_ref != HeightSensor::RANGE) {
|
||||||
// If the height is relative to the ground, terrain height cannot be observed.
|
// If the height is relative to the ground, terrain height cannot be observed.
|
||||||
_hagl_sensor_status.flags.flow = true;
|
_hagl_sensor_status.flags.flow = true;
|
||||||
@@ -135,27 +133,29 @@ void Ekf::startFlowFusion()
|
|||||||
|
|
||||||
if (isHorizontalAidingActive()) {
|
if (isHorizontalAidingActive()) {
|
||||||
if (fuseOptFlow(_hagl_sensor_status.flags.flow)) {
|
if (fuseOptFlow(_hagl_sensor_status.flags.flow)) {
|
||||||
ECL_INFO("starting optical flow no reset");
|
ECL_INFO("starting optical flow");
|
||||||
|
_control_status.flags.opt_flow = true;
|
||||||
|
|
||||||
} else if (_hagl_sensor_status.flags.flow && !_hagl_sensor_status.flags.range_finder) {
|
} else if (_hagl_sensor_status.flags.flow && !_hagl_sensor_status.flags.range_finder) {
|
||||||
|
ECL_INFO("starting optical flow, resetting terrain");
|
||||||
resetTerrainToFlow();
|
resetTerrainToFlow();
|
||||||
|
_control_status.flags.opt_flow = true;
|
||||||
} else {
|
|
||||||
ECL_INFO("optical flow fusion failed to start");
|
|
||||||
_control_status.flags.opt_flow = false;
|
|
||||||
_hagl_sensor_status.flags.flow = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (isTerrainEstimateValid() || (_height_sensor_ref == HeightSensor::RANGE)) {
|
if (isTerrainEstimateValid() || (_height_sensor_ref == HeightSensor::RANGE)) {
|
||||||
|
ECL_INFO("starting optical flow, resetting");
|
||||||
resetFlowFusion();
|
resetFlowFusion();
|
||||||
|
_control_status.flags.opt_flow = true;
|
||||||
|
|
||||||
} else if (_hagl_sensor_status.flags.flow) {
|
} else if (_hagl_sensor_status.flags.flow) {
|
||||||
|
ECL_INFO("starting optical flow, resetting terrain");
|
||||||
resetTerrainToFlow();
|
resetTerrainToFlow();
|
||||||
|
_control_status.flags.opt_flow = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_control_status.flags.opt_flow = true; // needs to be here because of isHorizontalAidingActive
|
_hagl_sensor_status.flags.flow = _control_status.flags.opt_flow && !(_height_sensor_ref == HeightSensor::RANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ekf::resetFlowFusion()
|
void Ekf::resetFlowFusion()
|
||||||
|
|||||||
Reference in New Issue
Block a user