use in_air flag from land detector to determine if we are on the ground

This commit is contained in:
Roman Bapst 2016-03-03 10:46:48 +01:00
parent 569886a4fc
commit b2744f965d
1 changed files with 4 additions and 3 deletions

View File

@ -198,12 +198,13 @@ void Ekf::calculateVehicleStatus()
}
// Transition to in-air occurs when armed and when altitude has increased sufficiently from the altitude at arming
if (!_control_status.flags.in_air && _control_status.flags.armed && (_state.pos(2) - _last_disarmed_posD) < -1.0f) {
bool in_air = _control_status.flags.armed && (_state.pos(2) - _last_disarmed_posD) < -1.0f;
if (!_control_status.flags.in_air && in_air) {
_control_status.flags.in_air = true;
}
// Transition to on-ground occurs when disarmed.
if (_control_status.flags.in_air && !_control_status.flags.armed) {
// Transition to on-ground occurs when disarmed or if the land detector indicated landed state
if (_control_status.flags.in_air && (!_control_status.flags.armed || !_in_air)) {
_control_status.flags.in_air = false;
}
}