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

Show supervisor info #682

Merged
merged 2 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
32 changes: 26 additions & 6 deletions src/cfclient/ui/tabs/FlightTab.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
import cfclient
from cfclient.ui.widgets.ai import AttitudeIndicator

from cfclient.utils.config import Config
from cflib.crazyflie.log import LogConfig

from cfclient.utils.config import Config
from cfclient.utils.input import JoystickReader

from cfclient.ui.tab_toolbox import TabToolbox
Expand Down Expand Up @@ -191,7 +191,7 @@ def __init__(self, helper):
# Supervisor
self._supervisor_info_bitfield = 0
self.armButton.clicked.connect(self.updateArm)
self._update_arm_button(False)
self._update_supervisor_and_arming(False)

self.uiSetupReady()

Expand Down Expand Up @@ -301,7 +301,7 @@ def _log_data_received(self, timestamp, data, logconf):
if self.LOG_NAME_SUPERVISOR_INFO in data:
self._supervisor_info_bitfield = data[self.LOG_NAME_SUPERVISOR_INFO]

self._update_arm_button(True)
self._update_supervisor_and_arming(True)

def _pose_data_received(self, pose_logger, pose):
if self.isVisible():
Expand Down Expand Up @@ -355,19 +355,36 @@ def _change_input_labels(self, using_hover_assist):
self.inputRollLabel.setText(roll)
self.inputYawLabel.setText(yaw)

def _update_arm_button(self, connected):
def _update_supervisor_and_arming(self, connected):
if not connected:
self.armButton.setStyleSheet("")
self.armButton.setText("Arm")
self.armButton.setEnabled(False)
self._supervisor_state.setText("")
self._supervisor_state.setStyleSheet("")
self._supervisor_state.setText("")
return

# We could set the text to "ready" or similar here, but an empty string is better for backwards compatibility as
# it would show "Ready" when locked for an older firmware.
self._supervisor_state.setText("")

if self._is_flying():
self.armButton.setEnabled(True)
self.armButton.setText("Emergency stop")
self.armButton.setStyleSheet("background-color: red")
self._supervisor_state.setText("Flying")
return

if self._is_tumbled():
self._supervisor_state.setText("Tumbled")

if self._is_locked():
self._supervisor_state.setText("Locked - reboot")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried this and the wording was a bit confusing. as it sseemed like it was locked and then was going to reboot by itself. It doesn't incite an action.

Perhaps 'Locked - please reboot' or someting?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point!
The space is limited though, the best I can come up with that fits is "Locked-pls reboot"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the please part but perhaps something like "Locked -> reboot" looks better? That is not so clear that an action is needed though.

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

if self._is_armed():
self.armButton.setStyleSheet("background-color: red")
if self._auto_arming():
Expand Down Expand Up @@ -503,7 +520,7 @@ def disconnected(self, linkURI):
self._update_flight_commander(False)

self._supervisor_info_bitfield = 0
self._update_arm_button(False)
self._update_supervisor_and_arming(False)

def _can_arm(self):
return bool(self._supervisor_info_bitfield & 0x0001)
Expand All @@ -523,6 +540,9 @@ def _is_flying(self):
def _is_tumbled(self):
return bool(self._supervisor_info_bitfield & 0x0020)

def _is_locked(self):
return bool(self._supervisor_info_bitfield & 0x0040)

def minMaxThrustChanged(self):
self._helper.inputDeviceReader.min_thrust = self.minThrust.value()
self._helper.inputDeviceReader.max_thrust = self.maxThrust.value()
Expand Down Expand Up @@ -685,7 +705,7 @@ def _all_params_updated(self):
self._ring_populate_dropdown()
self._populate_assisted_mode_dropdown()
self._update_flight_commander(True)
self._update_arm_button(True)
self._update_supervisor_and_arming(True)

def _ring_populate_dropdown(self):
try:
Expand Down
Loading