Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add indicator if crashed and recovery for the supervisor #700

Merged
merged 2 commits into from
Feb 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/cfclient/ui/tabs/FlightTab.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,29 @@ def _update_supervisor_and_arming(self, connected):
self._supervisor_state.setText("Tumbled")

if self._is_locked():
self.armButton.setText("")
self.armButton.setEnabled(False)
self.armButton.setStyleSheet("")
self._supervisor_state.setText("Locked-please reboot")
self._supervisor_state.setStyleSheet("background-color: red")
return
else:
self._supervisor_state.setStyleSheet("")

if self._is_crashed():
self.armButton.setText("Recover")
if self._is_tumbled():
self.armButton.setEnabled(False)
self.armButton.setStyleSheet("")
self._supervisor_state.setText("Crashed, flip over to recover")
else:
self.armButton.setEnabled(True)
self.armButton.setStyleSheet("background-color: red")
self._supervisor_state.setText("Crashed, click Recover")

self._supervisor_state.setStyleSheet("background-color: red")
return

if self._is_flying():
self.armButton.setEnabled(True)
self.armButton.setText("Emergency stop")
Expand Down Expand Up @@ -544,6 +562,9 @@ def _is_tumbled(self):
def _is_locked(self):
return bool(self._supervisor_info_bitfield & 0x0040)

def _is_crashed(self):
return bool(self._supervisor_info_bitfield & 0x0080)

def minMaxThrustChanged(self):
self._helper.inputDeviceReader.min_thrust = self.minThrust.value()
self._helper.inputDeviceReader.max_thrust = self.maxThrust.value()
Expand Down Expand Up @@ -621,6 +642,8 @@ def updateArm(self):
if self._is_flying():
self._helper.cf.loc.send_emergency_stop()
# TODO krri disarm?
if self._is_crashed():
self._helper.cf.platform.send_crash_recovery_request()
else:
if self._is_armed():
self._helper.cf.platform.send_arming_request(False)
Expand Down
Loading