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

Added arming fuctionality and emergency button #665

Merged
merged 17 commits into from
May 31, 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
18 changes: 12 additions & 6 deletions src/cfclient/ui/dialogs/inputconfigdialogue.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,12 @@ def __init__(self, joystickReader, *args):
"Press the button for Roll negative calibration"))
self.detectKillswitch.clicked.connect(
lambda: self._button_detect(
"killswitch", "Killswitch",
"Press the button for the killswitch (will disable motors)"))
"estop", "Disarm/Kill",
"Press the button to disarm/kill (will disable motors)"))
self.detectArm.clicked.connect(
lambda: self._button_detect(
"arm", "Arm system",
"Press the button to arm the system (will enable motor ouput)"))
self.detectAlt1.clicked.connect(
lambda: self._button_detect(
"alt1", "Alternative function 1",
Expand Down Expand Up @@ -142,9 +146,10 @@ def __init__(self, joystickReader, *args):
self.detectYaw, self.detectThrust,
self.detectPitchPos, self.detectPitchNeg,
self.detectRollPos, self.detectRollNeg,
self.detectKillswitch, self.detectExitapp,
self._detect_assisted_control, self.detectAlt1,
self.detectAlt2, self.detectMuxswitch]
self.detectKillswitch, self.detectArm,
self.detectExitapp, self._detect_assisted_control,
self.detectAlt1, self.detectAlt2,
self.detectMuxswitch]

self._button_to_detect = ""
self._axis_to_detect = ""
Expand Down Expand Up @@ -178,7 +183,8 @@ def _reset_mapping(self):
"pitchNeg": self.pitchNeg,
"rollPos": self.rollPos,
"rollNeg": self.rollNeg,
"killswitch": self.killswitch,
"estop": self.killswitch,
Copy link
Member

Choose a reason for hiding this comment

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

I was wondering... do we want to force people to choose a kill button? Like, they can not save the config file if there is no pitch yaw roll and thrust assigned... but we can also force people to choose a kill button. This needs to be for both the crazyflie or bolt based systems I suppose.

Copy link
Member Author

Choose a reason for hiding this comment

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

Might be a good idea but could there be joysticks without buttons? Then it would block those, which might be good...

"arm": self.arm,
"alt1": self.alt1,
"alt2": self.alt2,
"exitapp": self.exitapp,
Expand Down
83 changes: 53 additions & 30 deletions src/cfclient/ui/dialogs/inputconfigdialogue.ui
Original file line number Diff line number Diff line change
Expand Up @@ -505,13 +505,13 @@
<property name="geometry">
<rect>
<x>600</x>
<y>158</y>
<y>150</y>
<width>292</width>
<height>202</height>
<height>221</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="5" column="1">
<item row="6" column="1">
<widget class="QPushButton" name="detectAlt2">
<property name="enabled">
<bool>false</bool>
Expand All @@ -521,7 +521,30 @@
</property>
</widget>
</item>
<item row="4" column="0">
<item row="2" column="1">
<widget class="QPushButton" name="detectKillswitch">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Detect</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QCheckBox" name="muxswitch">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Mux switch</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="alt1">
<property name="enabled">
<bool>false</bool>
Expand All @@ -534,8 +557,8 @@
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QPushButton" name="detectExitapp">
<item row="1" column="1">
<widget class="QPushButton" name="_detect_assisted_control">
Copy link
Member

Choose a reason for hiding this comment

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

We should probably unify to make this all snake cases, but that is just a beauty issue.

Copy link
Member Author

Choose a reason for hiding this comment

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

Had the same idea but it generated a lot of side work as many of them are saved as button mapping

<property name="enabled">
<bool>false</bool>
</property>
Expand All @@ -544,30 +567,33 @@
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="detectKillswitch">
<item row="6" column="0">
<widget class="QCheckBox" name="alt2">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Detect</string>
<string>Alt 2</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="killswitch">
<item row="1" column="0">
<widget class="QCheckBox" name="_assisted_control">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Killswitch</string>
<string>Assisted control</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<item row="4" column="0">
<widget class="QCheckBox" name="exitapp">
<property name="enabled">
<bool>false</bool>
Expand All @@ -580,21 +606,21 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="_assisted_control">
<item row="2" column="0">
<widget class="QCheckBox" name="killswitch">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Assisted control</string>
<string>Disarm/kill</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="_detect_assisted_control">
<item row="7" column="1">
<widget class="QPushButton" name="detectMuxswitch">
<property name="enabled">
<bool>false</bool>
</property>
Expand All @@ -603,21 +629,18 @@
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="alt2">
<item row="5" column="1">
<widget class="QPushButton" name="detectAlt1">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Alt 2</string>
</property>
<property name="checkable">
<bool>true</bool>
<string>Detect</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QPushButton" name="detectAlt1">
<widget class="QPushButton" name="detectExitapp">
<property name="enabled">
<bool>false</bool>
</property>
Expand All @@ -626,21 +649,21 @@
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="muxswitch">
<item row="3" column="0">
<widget class="QCheckBox" name="arm">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Mux switch</string>
<string>Arm</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QPushButton" name="detectMuxswitch">
<item row="3" column="1">
<widget class="QPushButton" name="detectArm">
<property name="enabled">
<bool>false</bool>
</property>
Expand Down
9 changes: 9 additions & 0 deletions src/cfclient/ui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ def __init__(self, *args):
self.joystickReader.hover_input_updated.add_callback(
self.cf.commander.send_hover_setpoint)

#Emergency stop button
self.esButton.clicked.connect(self._emergency_stop)

# Connection callbacks and signal wrappers for UI protection
self.cf.connected.add_callback(self.connectionDoneSignal.emit)
self.connectionDoneSignal.connect(self._connected)
Expand Down Expand Up @@ -562,6 +565,12 @@ def _show_input_device_config_dialog(self):
def _show_connect_dialog(self):
self.logConfigDialogue.show()

def _emergency_stop(self):
#send disarming command
if (self.uiState == UIState.CONNECTED):
Copy link
Member

Choose a reason for hiding this comment

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

I found here, if there is a firmware on the crazyflie that does not have 'system.arm' on there, the button 'arm and disarm' is active still and the terminal says:

WARNING:cflib.crazyflie.toc:Unable to find variable [system.arm]
WARNING:cflib.crazyflie.param:Cannot set value for [system.arm], it's not in the TOC!

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, yes the variable name us new but I guess this is avoidable for all new parameters that are used in e.g. the cfclient UI. Perhaps the warning is a good thing then?

Copy link
Member Author

Choose a reason for hiding this comment

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

A bigger problem might be that the emergency button will not work...

self.cf.param.set_value("system.arm", int(False))


def _update_battery(self, timestamp, data, logconf):
self.batteryBar.setValue(int(data["pm.vbat"] * 1000))

Expand Down
Loading