From 10044d59aaa762246573b9e69d4db728a0dcb622 Mon Sep 17 00:00:00 2001 From: victor Date: Tue, 28 Jul 2020 15:49:14 +0200 Subject: [PATCH 1/2] Removed support for x-mode. Removed all traces for x-mode since this is no longer needed because crazyflie 1.0 isn't supported anymore. --- docs/development/dev_info_client.md | 3 - docs/userguides/cfheadless.md | 1 - examples/zmqsrvtest.py | 16 --- src/cfclient/configs/config.json | 1 - src/cfclient/headless.py | 13 +-- src/cfclient/ui/tabs/FlightTab.py | 30 ------ src/cfclient/ui/tabs/flightTab.ui | 144 +++++++++++--------------- src/cfclient/ui/widgets/plotwidget.py | 12 --- 8 files changed, 64 insertions(+), 156 deletions(-) diff --git a/docs/development/dev_info_client.md b/docs/development/dev_info_client.md index b6da440030..f56a85e04b 100644 --- a/docs/development/dev_info_client.md +++ b/docs/development/dev_info_client.md @@ -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, @@ -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| @@ -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, diff --git a/docs/userguides/cfheadless.md b/docs/userguides/cfheadless.md index 908f2cc270..873095ab6c 100644 --- a/docs/userguides/cfheadless.md +++ b/docs/userguides/cfheadless.md @@ -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 diff --git a/examples/zmqsrvtest.py b/examples/zmqsrvtest.py index 2837491ef5..e2bf4128ba 100644 --- a/examples/zmqsrvtest.py +++ b/examples/zmqsrvtest.py @@ -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) diff --git a/src/cfclient/configs/config.json b/src/cfclient/configs/config.json index bb92591efe..f284837ac3 100644 --- a/src/cfclient/configs/config.json +++ b/src/cfclient/configs/config.json @@ -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, diff --git a/src/cfclient/headless.py b/src/cfclient/headless.py index 29dca85ef7..ee58fa474f 100644 --- a/src/cfclient/headless.py +++ b/src/cfclient/headless.py @@ -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]) @@ -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: @@ -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!") diff --git a/src/cfclient/ui/tabs/FlightTab.py b/src/cfclient/ui/tabs/FlightTab.py index a987d970a5..edf322c2a5 100644 --- a/src/cfclient/ui/tabs/FlightTab.py +++ b/src/cfclient/ui/tabs/FlightTab.py @@ -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", @@ -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: @@ -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): @@ -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) @@ -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) diff --git a/src/cfclient/ui/tabs/flightTab.ui b/src/cfclient/ui/tabs/flightTab.ui index 659d8d7abb..7cfe02c768 100644 --- a/src/cfclient/ui/tabs/flightTab.ui +++ b/src/cfclient/ui/tabs/flightTab.ui @@ -50,62 +50,29 @@ - - - - - 0 - 0 - - - - <html><head/><body><p>Select what flightmode to use:</p><p> * Safe prevents crashing</p><p> * Crazy does not prevent crashing :)</p></body></html> + + + + -20.000000000000000 - - false + + 20.000000000000000 - - 0 + + 0.200000000000000 - - - Normal - - - - - Advanced - - - - - - Qt::Vertical - - - QSizePolicy::Maximum - - - - 0 - 0 - + + + + false - - - - - Assist mode + Attitude control - - - - - - false + + true @@ -116,8 +83,8 @@ - - + + -20.000000000000000 @@ -129,16 +96,10 @@ - - - - -20.000000000000000 - - - 20.000000000000000 - - - 0.200000000000000 + + + + false @@ -163,45 +124,64 @@ - + false - Crazyflie X-mode + Rate control - - - + + + + + 0 + 0 + + + + <html><head/><body><p>Select what flightmode to use:</p><p> * Safe prevents crashing</p><p> * Crazy does not prevent crashing :)</p></body></html> + + false - - Client X-mode + + 0 + + + Normal + + + + + Advanced + + - - - - false + + + + Qt::Vertical - - Attitude control + + QSizePolicy::Maximum - - true + + + 0 + 0 + - + - - - - false - + + - Rate control + Assist mode diff --git a/src/cfclient/ui/widgets/plotwidget.py b/src/cfclient/ui/widgets/plotwidget.py index 19a5f46b15..53f6891e83 100644 --- a/src/cfclient/ui/widgets/plotwidget.py +++ b/src/cfclient/ui/widgets/plotwidget.py @@ -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) @@ -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: From 99a2c77ee4e1610549edf53c1cb6207c05277f8e Mon Sep 17 00:00:00 2001 From: victor Date: Tue, 28 Jul 2020 15:49:25 +0200 Subject: [PATCH 2/2] Removed unused import --- src/cfclient/ui/tabs/FlightTab.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cfclient/ui/tabs/FlightTab.py b/src/cfclient/ui/tabs/FlightTab.py index edf322c2a5..943c7a3475 100644 --- a/src/cfclient/ui/tabs/FlightTab.py +++ b/src/cfclient/ui/tabs/FlightTab.py @@ -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