Copter: use height-above-ground for landing gear deployment

This commit is contained in:
Peter Barker 2019-02-23 09:39:08 +11:00 committed by Randy Mackay
parent 078eef91cb
commit 8e1b48ef1e

View File

@ -29,8 +29,8 @@ void Copter::landinggear_update()
last_deploy_status = landinggear.deployed();
// support height based triggering using rangefinder or altitude above home
float height = current_loc.alt * 0.01;
// support height based triggering using rangefinder or altitude above ground
int32_t height_cm = flightmode->get_alt_above_ground();
// use rangefinder if available
switch (rangefinder.status_orient(ROTATION_PITCH_270)) {
@ -41,15 +41,15 @@ void Copter::landinggear_update()
case RangeFinder::RangeFinder_OutOfRangeLow:
// altitude is close to zero (gear should deploy)
height = 0.0f;
height_cm = 0;
break;
case RangeFinder::RangeFinder_OutOfRangeHigh:
case RangeFinder::RangeFinder_Good:
// use last good reading
height = rangefinder_state.alt_cm_filt.get() * 0.01;
height_cm = rangefinder_state.alt_cm_filt.get();
break;
}
landinggear.update(height);
landinggear.update(height_cm * 0.01f); // convert cm->m for update call
}