Skip to content

Commit

Permalink
Merge pull request bitcraze#420 from victorhook/issue_400
Browse files Browse the repository at this point in the history
Removed support for Crazyflie x-mode in client
  • Loading branch information
krichardsson authored Jul 28, 2020
2 parents ca748ac + fb3aa9c commit 3553bad
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 157 deletions.
3 changes: 0 additions & 3 deletions docs/development/dev_info_client.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ configuration file.

``` {.json}
{
"client_side_xmode": false,
"link_uri": "radio://0/100/250K",
"input_device": "Sony PLAYSTATION(R)3 Controller",
"slew_limit": 45,
Expand Down Expand Up @@ -128,7 +127,6 @@ configuration file.

| Field | Format | Comments |
| -------------------------- | --------- | -------- |
| client\_side\_xmode | boolean | Sets whether the client side X-mode is activated or not (more info here)|
| link\_uri | string | The last successfully connected Crazyflie URI. This is used when you click \"Quick connect\" in the application|
| auto\_reconnect | boolean | Set\'s if auto-reconnect is enabled or not|
| ui\_update\_period | int | The minimum time (in ms) between UI updates for logging values|
Expand Down Expand Up @@ -177,7 +175,6 @@ accessed in the application.
"min_thrust": 25,
"max_yaw": 200,
"max_rp": 30,
"client_side_xmode": false,
"auto_reconnect": false,
"device_config_mapping": {},
"enable_debug_driver": false,
Expand Down
1 change: 0 additions & 1 deletion docs/userguides/cfheadless.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ optional arguments:
-c CONTROLLER, --controller CONTROLLER
Use controller with specified id, id defaults to 0
--controllers Only display available controllers and exit
-x, --x-mode Enable client-side X-mode
```
The client is exited either by taking out the Crazyradio USB dongle or
pressing Ctrl+C
Expand Down
16 changes: 0 additions & 16 deletions examples/zmqsrvtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,22 +243,6 @@ def run(self):
"value": True
}

print("Setting param {} to {}...".format(param_cmd["name"],
param_cmd["value"]), end=' ')
client_conn.send_json(param_cmd)
resp = client_conn.recv_json()
if resp["status"] == 0:
print("done!")
else:
print("fail! {}".format(resp["msg"]))

param_cmd = {
"version": 1,
"cmd": "param",
"name": "flightctrl.xmode",
"value": True
}

print("Setting param {} to {}...".format(param_cmd["name"],
param_cmd["value"]), end=' ')
client_conn.send_json(param_cmd)
Expand Down
1 change: 0 additions & 1 deletion src/cfclient/configs/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"min_thrust": 25,
"max_yaw": 200,
"max_rp": 30,
"client_side_xmode": false,
"auto_reconnect": false,
"device_config_mapping": {},
"enable_debug_driver": false,
Expand Down
13 changes: 2 additions & 11 deletions src/cfclient/headless.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,9 @@ def __init__(self):
for d in self._jr.available_devices():
self._devs.append(d.name)

def setup_controller(self, input_config, input_device=0, xmode=False):
def setup_controller(self, input_config, input_device=0):
"""Set up the device reader"""
# Set up the joystick reader
self._jr.device_error.add_callback(self._input_dev_error)
print("Client side X-mode: %s" % xmode)
if (xmode):
self._cf.commander.set_client_xmode(xmode)

devs = self._jr.available_devices() # noqa, is this a bug?
print("Will use [%s] for input" % self._devs[input_device])
self._jr.start_input(self._devs[input_device])
Expand Down Expand Up @@ -145,9 +140,6 @@ def main():
parser.add_argument("--controllers", action="store_true",
dest="list_controllers",
help="Only display available controllers and exit")
parser.add_argument("-x", "--x-mode", action="store_true",
dest="xmode",
help="Enable client-side X-mode")
(args, unused) = parser.parse_known_args()

if args.debug:
Expand All @@ -162,8 +154,7 @@ def main():
else:
if headless.controller_connected():
headless.setup_controller(input_config=args.input,
input_device=args.controller,
xmode=args.xmode)
input_device=args.controller)
headless.connect_crazyflie(link_uri=args.uri)
else:
print("No input-device connected, exiting!")
Expand Down
32 changes: 1 addition & 31 deletions src/cfclient/ui/tabs/FlightTab.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import logging

from PyQt5 import uic
from PyQt5.QtCore import Qt, pyqtSlot, pyqtSignal
from PyQt5.QtCore import Qt, pyqtSignal
from PyQt5.QtWidgets import QMessageBox

import cfclient
Expand Down Expand Up @@ -142,21 +142,9 @@ def __init__(self, tabWidget, helper, *args):
self.maxAngle.valueChanged.connect(self.maxAngleChanged)
self.maxYawRate.valueChanged.connect(self.maxYawRateChanged)
self.uiSetupReadySignal.connect(self.uiSetupReady)
self.clientXModeCheckbox.toggled.connect(self.changeXmode)
self.isInCrazyFlightmode = False
self.uiSetupReady()

self.clientXModeCheckbox.setChecked(Config().get("client_side_xmode"))

self.crazyflieXModeCheckbox.clicked.connect(
lambda enabled:
self.helper.cf.param.set_value("flightmode.x",
str(enabled)))
self.helper.cf.param.add_update_callback(
group="flightmode", name="xmode",
cb=(lambda name, checked:
self.crazyflieXModeCheckbox.setChecked(eval(checked))))

self.ratePidRadioButton.clicked.connect(
lambda enabled:
self.helper.cf.param.set_value("flightmode.ratepid",
Expand All @@ -177,10 +165,6 @@ def __init__(self, tabWidget, helper, *args):
cb=(lambda name, checked:
self.ratePidRadioButton.setChecked(eval(checked))))

self.helper.cf.param.add_update_callback(
group="cpu", name="flash",
cb=self._set_enable_client_xmode)

self.helper.cf.param.add_update_callback(
group="ring", name="headlightEnable",
cb=(lambda name, checked:
Expand Down Expand Up @@ -222,13 +206,6 @@ def __init__(self, tabWidget, helper, *args):
self._limiting_updated.emit)
self._limiting_updated.connect(self._set_limiting_enabled)

def _set_enable_client_xmode(self, name, value):
if eval(value) <= 128:
self.clientXModeCheckbox.setEnabled(True)
else:
self.clientXModeCheckbox.setEnabled(False)
self.clientXModeCheckbox.setChecked(False)

def _set_limiting_enabled(self, rp_limiting_enabled,
yaw_limiting_enabled,
thrust_limiting_enabled):
Expand Down Expand Up @@ -377,7 +354,6 @@ def disconnected(self, linkURI):
self.ai.setHover(0, self.is_visible())
self.targetHeight.setEnabled(False)
self.actualHeight.setEnabled(False)
self.clientXModeCheckbox.setEnabled(False)
self.logBaro = None
self.logAltHold = None
self._led_ring_effect.setEnabled(False)
Expand Down Expand Up @@ -536,12 +512,6 @@ def _assisted_control_updated(self, enabled):
else:
self.helper.cf.param.set_value("flightmode.althold", str(enabled))

@pyqtSlot(bool)
def changeXmode(self, checked):
self.helper.cf.commander.set_client_xmode(checked)
Config().set("client_side_xmode", checked)
logger.info("Clientside X-mode enabled: %s", checked)

def alt1_updated(self, state):
if state:
new_index = (self._ring_effect+1) % (self._ledring_nbr_effects+1)
Expand Down
144 changes: 62 additions & 82 deletions src/cfclient/ui/tabs/flightTab.ui
Original file line number Diff line number Diff line change
Expand Up @@ -50,62 +50,29 @@
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="1">
<widget class="QComboBox" name="flightModeCombo">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Select what flightmode to use:&lt;/p&gt;&lt;p&gt; * Safe prevents crashing&lt;/p&gt;&lt;p&gt; * Crazy does not prevent crashing :)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<item row="3" column="1">
<widget class="QDoubleSpinBox" name="targetCalRoll">
<property name="minimum">
<double>-20.000000000000000</double>
</property>
<property name="editable">
<bool>false</bool>
<property name="maximum">
<double>20.000000000000000</double>
</property>
<property name="currentIndex">
<number>0</number>
<property name="singleStep">
<double>0.200000000000000</double>
</property>
<item>
<property name="text">
<string>Normal</string>
</property>
</item>
<item>
<property name="text">
<string>Advanced</string>
</property>
</item>
</widget>
</item>
<item row="0" column="1">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Maximum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
<item row="5" column="0">
<widget class="QRadioButton" name="angularPidRadioButton">
<property name="enabled">
<bool>false</bool>
</property>
</spacer>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Assist mode</string>
<string>Attitude control</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="_assist_mode_combo">
<property name="enabled">
<bool>false</bool>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
Expand All @@ -116,8 +83,8 @@
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QDoubleSpinBox" name="targetCalRoll">
<item row="4" column="1">
<widget class="QDoubleSpinBox" name="targetCalPitch">
<property name="minimum">
<double>-20.000000000000000</double>
</property>
Expand All @@ -129,16 +96,10 @@
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QDoubleSpinBox" name="targetCalPitch">
<property name="minimum">
<double>-20.000000000000000</double>
</property>
<property name="maximum">
<double>20.000000000000000</double>
</property>
<property name="singleStep">
<double>0.200000000000000</double>
<item row="2" column="1">
<widget class="QComboBox" name="_assist_mode_combo">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
Expand All @@ -163,45 +124,64 @@
</widget>
</item>
<item row="5" column="1">
<widget class="QCheckBox" name="crazyflieXModeCheckbox">
<widget class="QRadioButton" name="ratePidRadioButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Crazyflie X-mode</string>
<string>Rate control</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="clientXModeCheckbox">
<property name="enabled">
<item row="1" column="1">
<widget class="QComboBox" name="flightModeCombo">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Select what flightmode to use:&lt;/p&gt;&lt;p&gt; * Safe prevents crashing&lt;/p&gt;&lt;p&gt; * Crazy does not prevent crashing :)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="editable">
<bool>false</bool>
</property>
<property name="text">
<string>Client X-mode</string>
<property name="currentIndex">
<number>0</number>
</property>
<item>
<property name="text">
<string>Normal</string>
</property>
</item>
<item>
<property name="text">
<string>Advanced</string>
</property>
</item>
</widget>
</item>
<item row="6" column="0">
<widget class="QRadioButton" name="angularPidRadioButton">
<property name="enabled">
<bool>false</bool>
<item row="0" column="1">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="text">
<string>Attitude control</string>
<property name="sizeType">
<enum>QSizePolicy::Maximum</enum>
</property>
<property name="checked">
<bool>true</bool>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</spacer>
</item>
<item row="6" column="1">
<widget class="QRadioButton" name="ratePidRadioButton">
<property name="enabled">
<bool>false</bool>
</property>
<item row="2" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Rate control</string>
<string>Assist mode</string>
</property>
</widget>
</item>
Expand Down
12 changes: 0 additions & 12 deletions src/cfclient/ui/widgets/plotwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ def __init__(self, parent=None, fps=100, title="", *args):
self._x_btn_group.addButton(self._enable_seconds_x)
self._x_btn_group.addButton(self._enable_manual_x)
self._x_btn_group.setExclusive(True)
self._x_btn_group.buttonClicked.connect(self._x_mode_change)

self._draw_graph = True
self._auto_redraw.stateChanged.connect(self._auto_redraw_change)
Expand All @@ -190,17 +189,6 @@ def _auto_redraw_change(self, state):
else:
self._draw_graph = True

def _x_mode_change(self, box):
"""Callback when user changes the X-axis mode"""
if box == self._enable_range_x:
logger.info("Enable range x")
self._x_range = (
float(self._range_x_min.text()),
float(self._range_x_max.text()))
else:
self._range_x_min.setEnabled(False)
self._range_x_max.setEnabled(False)

def _y_mode_change(self, box):
"""Callback when user changes the Y-axis mode"""
if box == self._enable_range_y:
Expand Down

0 comments on commit 3553bad

Please sign in to comment.