FlightTask Manual: Gear react only on switch changes and not states

This commit is contained in:
Simone Guscetti 2018-11-06 15:48:14 +01:00 committed by Dennis Mannhart
parent f4fc0cd291
commit 9ee3d79a96
2 changed files with 4 additions and 6 deletions

View File

@ -91,15 +91,12 @@ bool FlightTaskManual::_evaluateSticks()
// 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 (!_gear.landing_gear) {
if (gear_switch == manual_control_setpoint_s::SWITCH_POS_OFF) {
_applyGearSwitch(gear_switch);
}
} else {
if (_gear_switch_old != gear_switch) {
_applyGearSwitch(gear_switch);
}
_gear_switch_old = gear_switch;
// valid stick inputs are required
const bool valid_sticks = PX4_ISFINITE(_sticks(0))
&& PX4_ISFINITE(_sticks(1))

View File

@ -59,6 +59,7 @@ protected:
bool _sticks_data_required = true; /**< let inherited task-class define if it depends on stick data */
matrix::Vector<float, 4> _sticks; /**< unmodified manual stick inputs */
matrix::Vector<float, 4> _sticks_expo; /**< modified manual sticks using expo function*/
int _gear_switch_old = manual_control_setpoint_s::SWITCH_POS_NONE; /**< old switch state*/
float stickDeadzone() const { return _stick_dz.get(); }