mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-07 13:10:34 +08:00
FlightTask: apply gear switch depending on task
This commit is contained in:
committed by
Lorenz Meier
parent
c637ccb65f
commit
547cdc051c
@@ -81,12 +81,38 @@ bool FlightTaskManual::_evaluateSticks()
|
||||
_sticks_expo(1) = math::expo_deadzone(_sticks(1), _xy_vel_man_expo.get(), _stick_dz.get());
|
||||
_sticks_expo(2) = math::expo_deadzone(_sticks(2), _z_vel_man_expo.get(), _stick_dz.get());
|
||||
|
||||
// Only switch the landing gear up if the user switched from gear down to gear up.
|
||||
// If the user had the switch in the gear up position and took off ignore it
|
||||
// until he toggles the switch to avoid retracting the gear immediately on takeoff.
|
||||
int8_t gear_switch = _sub_manual_control_setpoint->get().gear_switch;
|
||||
|
||||
if (!_constraints.landing_gear) {
|
||||
if (gear_switch == manual_control_setpoint_s::SWITCH_POS_OFF) {
|
||||
_applyGearSwitch(gear_switch);
|
||||
}
|
||||
|
||||
} else {
|
||||
_applyGearSwitch(gear_switch);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
} else {
|
||||
/* Timeout: set all sticks to zero */
|
||||
_sticks.zero();
|
||||
_sticks_expo.zero();
|
||||
_constraints.landing_gear = vehicle_constraints_s::GEAR_KEEP;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void FlightTaskManual::_applyGearSwitch(uint8_t gswitch)
|
||||
{
|
||||
if (gswitch == manual_control_setpoint_s::SWITCH_POS_OFF) {
|
||||
_constraints.landing_gear = vehicle_constraints_s::GEAR_DOWN;
|
||||
}
|
||||
|
||||
if (gswitch == manual_control_setpoint_s::SWITCH_POS_ON) {
|
||||
_constraints.landing_gear = vehicle_constraints_s::GEAR_UP;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user