Skip to content

Commit

Permalink
More renaming of althold and assist mode to assited control (#280)
Browse files Browse the repository at this point in the history
  • Loading branch information
evoggy committed Feb 1, 2017
1 parent da5ac79 commit cdbf14b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/cfclient/headless.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
15 changes: 8 additions & 7 deletions src/cfclient/ui/tabs/FlightTab.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down
15 changes: 8 additions & 7 deletions src/cfclient/utils/input/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions src/cfclient/utils/input/inputreaderinterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit cdbf14b

Please sign in to comment.