From cdbf14b242196b321d78f7f13c1d51d8df53543f Mon Sep 17 00:00:00 2001 From: Marcus Eliasson Date: Wed, 1 Feb 2017 11:32:23 +0100 Subject: [PATCH] More renaming of althold and assist mode to assited control (#280) --- src/cfclient/headless.py | 2 +- src/cfclient/ui/tabs/FlightTab.py | 15 ++++++++------- src/cfclient/utils/input/__init__.py | 15 ++++++++------- src/cfclient/utils/input/inputreaderinterface.py | 6 +++--- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/cfclient/headless.py b/src/cfclient/headless.py index 49605af9..29dca85e 100644 --- a/src/cfclient/headless.py +++ b/src/cfclient/headless.py @@ -101,7 +101,7 @@ def connect_crazyflie(self, link_uri): group="imu_sensors", name="HMC5883L", cb=( lambda name, found: self._jr.set_alt_hold_available( eval(found)))) - self._jr.althold_updated.add_callback( + self._jr.assisted_control_updated.add_callback( lambda enabled: self._cf.param.set_value("flightmode.althold", enabled)) diff --git a/src/cfclient/ui/tabs/FlightTab.py b/src/cfclient/ui/tabs/FlightTab.py index 9b6de6b5..f2ec58e9 100644 --- a/src/cfclient/ui/tabs/FlightTab.py +++ b/src/cfclient/ui/tabs/FlightTab.py @@ -107,7 +107,7 @@ def __init__(self, tabWidget, helper, *args): self.helper.inputDeviceReader.emergency_stop_updated.add_callback( self._emergency_stop_updated_signal.emit) - self.helper.inputDeviceReader.althold_updated.add_callback( + self.helper.inputDeviceReader.assisted_control_updated.add_callback( lambda enabled: self.helper.cf.param.set_value( "flightmode.althold", enabled)) @@ -247,7 +247,7 @@ def uiSetupReady(self): try: assistmodeComboIndex = self._assist_mode_combo.findText( - Config().get("assistmode"), Qt.MatchFixedString) + Config().get("assistedControl"), Qt.MatchFixedString) except KeyError: assistmodeComboIndex = 0 if (flightComboIndex < 0): @@ -513,13 +513,14 @@ def flightmodeChange(self, item): self.maxYawRate.setEnabled(newState) def _assist_mode_changed(self, item): - Config().set("assistmode", str(self._assist_mode_combo.itemText(item))) + Config().set("assistedControl", str(self._assist_mode_combo. + itemText(item))) if (item == 0): # Altitude hold - self.helper.inputDeviceReader.assisted_mode = \ - JoystickReader.ASSIST_MODE_ALTHOLD + self.helper.inputDeviceReader.assisted_control = \ + JoystickReader.ASSISTED_CONTROL_ALTHOLD if (item == 1): # Position hold - self.helper.inputDeviceReader.assisted_mode = \ - JoystickReader.ASSIST_MODE_POSHOLD + self.helper.inputDeviceReader.assisted_control = \ + JoystickReader.ASSISTED_CONTROL_POSHOLD @pyqtSlot(bool) def changeXmode(self, checked): diff --git a/src/cfclient/utils/input/__init__.py b/src/cfclient/utils/input/__init__.py index 78334301..5cf59a51 100644 --- a/src/cfclient/utils/input/__init__.py +++ b/src/cfclient/utils/input/__init__.py @@ -73,8 +73,8 @@ class JoystickReader(object): """ inputConfig = [] - ASSIST_MODE_ALTHOLD = 0 - ASSIST_MODE_POSHOLD = 1 + ASSISTED_CONTROL_ALTHOLD = 0 + ASSISTED_CONTROL_POSHOLD = 1 def __init__(self, do_device_discovery=True): self._input_device = None @@ -89,9 +89,9 @@ def __init__(self, do_device_discovery=True): self.max_rp_angle = 0 self.max_yaw_rate = 0 try: - self.assisted_mode = Config().get("assistmode") + self.assisted_control = Config().get("assistedControl") except KeyError: - self.assisted_mode = JoystickReader.ASSIST_MODE_ALTHOLD + self.assisted_control = JoystickReader.ASSISTED_CONTROL_ALTHOLD self._old_thrust = 0 self._old_raw_thrust = 0 @@ -161,7 +161,7 @@ def __init__(self, do_device_discovery=True): self.emergency_stop_updated = Caller() self.device_discovery = Caller() self.device_error = Caller() - self.althold_updated = Caller() + self.assisted_control_updated = Caller() self.alt1_updated = Caller() self.alt2_updated = Caller() @@ -342,11 +342,12 @@ def read_input(self): if data: if data.toggled.assistedControl: try: - self.althold_updated.call(str(data.assistedControl)) + self.assisted_control_updated.call( + str(data.assistedControl)) except Exception as e: logger.warning( "Exception while doing callback from input-device " - "for althold: {}".format(e)) + "for assited control: {}".format(e)) if data.toggled.estop: try: diff --git a/src/cfclient/utils/input/inputreaderinterface.py b/src/cfclient/utils/input/inputreaderinterface.py index 10c4259e..41cd039b 100644 --- a/src/cfclient/utils/input/inputreaderinterface.py +++ b/src/cfclient/utils/input/inputreaderinterface.py @@ -164,10 +164,10 @@ def _scale_and_deadband_yaw(self, yaw): return (InputReaderInterface.deadband(yaw, 0.2) * self.input.max_yaw_rate) - def _limit_thrust(self, thrust, althold, emergency_stop): + def _limit_thrust(self, thrust, assisted_control, emergency_stop): # Thust limiting (slew, minimum and emergency stop) if self.input.springy_throttle: - if althold and self.input.has_pressure_sensor: + if assisted_control and self.input.has_pressure_sensor: thrust = int(round(InputReaderInterface.deadband(thrust, 0.2) * 32767 + 32767)) # Convert to uint16 else: @@ -217,7 +217,7 @@ def _limit_thrust(self, thrust, althold, emergency_stop): thrust = limited_thrust else: thrust = thrust / 2 + 0.5 - if althold and self.input.has_pressure_sensor: + if assisted_control and self.input.has_pressure_sensor: thrust = 32767 else: if thrust < -0.90 or emergency_stop: