From cc716e976b4430f59a3d59e81fae4e342098bdb6 Mon Sep 17 00:00:00 2001 From: Rik Bouwmeester Date: Mon, 21 Oct 2024 17:17:39 +0200 Subject: [PATCH] Allow in-flight disarming via controller without triggering emergency stop This commit updates the client to allow users controlling their drones with physical controllers to disarm the drone mid-flight. Previously, the disarm button on controllers was explicitly linked to triggering an emergency stop, preventing standard disarming during flight. With this change, pressing the disarm button on the controller will now safely disarm the drone, rather than activating an emergency stop. For emergency situations, users should continue using the dedicated emergency stop function, which is more reliable for halting the drone immediately. The (dis)arm controller button is still linked to crash recovery. UI arm/recover/emergency-stop button behavior is unchanged. Use together with https://github.com/bitcraze/crazyflie-firmware/pull/1426 --- src/cfclient/ui/tabs/FlightTab.py | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/cfclient/ui/tabs/FlightTab.py b/src/cfclient/ui/tabs/FlightTab.py index 86dc6f09..684e0e2c 100644 --- a/src/cfclient/ui/tabs/FlightTab.py +++ b/src/cfclient/ui/tabs/FlightTab.py @@ -138,7 +138,7 @@ def __init__(self, helper): self._emergency_stop_updated_signal.connect(self.updateEmergencyStop) self._helper.inputDeviceReader.emergency_stop_updated.add_callback( self._emergency_stop_updated_signal.emit) - self._arm_updated_signal.connect(self.updateArm) + self._arm_updated_signal.connect(lambda: self.updateArm(from_controller=True)) self._helper.inputDeviceReader.arm_updated.add_callback(self._arm_updated_signal.emit) self._helper.inputDeviceReader.heighthold_input_updated.add_callback( @@ -638,19 +638,16 @@ def updateEmergencyStop(self, emergencyStop): else: self.setMotorLabelsEnabled(True) - def updateArm(self): - if self._is_flying(): + def updateArm(self, from_controller=False): + if self._is_flying() and not from_controller: self._helper.cf.loc.send_emergency_stop() - # TODO krri disarm? - if self._is_crashed(): + elif self._is_crashed(): self._helper.cf.platform.send_crash_recovery_request() - else: - if self._is_armed(): - self._helper.cf.platform.send_arming_request(False) - else: - if self._can_arm(): - self.armButton.setStyleSheet("background-color: orange") - self._helper.cf.platform.send_arming_request(True) + elif self._is_armed(): + self._helper.cf.platform.send_arming_request(False) + elif self._can_arm(): + self.armButton.setStyleSheet("background-color: orange") + self._helper.cf.platform.send_arming_request(True) def flightmodeChange(self, item): Config().set("flightmode", str(self.flightModeCombo.itemText(item)))