Skip to content

Commit

Permalink
Allow in-flight disarming via controller without triggering emergency…
Browse files Browse the repository at this point in the history
… 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 bitcraze/crazyflie-firmware#1426
  • Loading branch information
gemenerik committed Oct 21, 2024
1 parent bfc728c commit cc716e9
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/cfclient/ui/tabs/FlightTab.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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)))
Expand Down

0 comments on commit cc716e9

Please sign in to comment.