|
|
@ -50,7 +50,7 @@ class RobotController:
|
|
|
|
:return:
|
|
|
|
:return:
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
self._interpret_buttons(dabble_bytes[0])
|
|
|
|
self._interpret_buttons(dabble_bytes[0])
|
|
|
|
self._interpret_arrows(dabble_bytes[1])
|
|
|
|
self._interpret_arrows(dabble_bytes[0], dabble_bytes[1])
|
|
|
|
|
|
|
|
|
|
|
|
def _interpret_buttons(self, button_byte):
|
|
|
|
def _interpret_buttons(self, button_byte):
|
|
|
|
if button_byte & (1 << DABBLE_START_BIT):
|
|
|
|
if button_byte & (1 << DABBLE_START_BIT):
|
|
|
@ -60,9 +60,21 @@ class RobotController:
|
|
|
|
self.robot.set_idle()
|
|
|
|
self.robot.set_idle()
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
self.robot.set_active()
|
|
|
|
self.robot.set_active()
|
|
|
|
|
|
|
|
# Speed control
|
|
|
|
def _interpret_arrows(self, arrow_byte):
|
|
|
|
if button_byte & (1 << DABBLE_TRIANGLE_BIT):
|
|
|
|
if arrow_byte & (1 << DABBLE_UP_BIT):
|
|
|
|
self.robot._vel += 0.2
|
|
|
|
|
|
|
|
elif button_byte & (1 << DABBLE_CROSS_BIT):
|
|
|
|
|
|
|
|
self.robot._vel -= 0.2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _interpret_arrows(self, button_byte, arrow_byte):
|
|
|
|
|
|
|
|
# Spin overrides arrow pad
|
|
|
|
|
|
|
|
if button_byte & (1 << DABBLE_CIRCLE_BIT):
|
|
|
|
|
|
|
|
self.robot.right_spin()
|
|
|
|
|
|
|
|
elif button_byte & (1 << DABBLE_SQUARE_BIT):
|
|
|
|
|
|
|
|
self.robot.left_spin()
|
|
|
|
|
|
|
|
# Arrow Pad assessment
|
|
|
|
|
|
|
|
elif arrow_byte & (1 << DABBLE_UP_BIT):
|
|
|
|
self.robot.forward()
|
|
|
|
self.robot.forward()
|
|
|
|
elif arrow_byte & (1 << DABBLE_DOWN_BIT):
|
|
|
|
elif arrow_byte & (1 << DABBLE_DOWN_BIT):
|
|
|
|
self.robot.reverse()
|
|
|
|
self.robot.reverse()
|
|
|
@ -119,11 +131,19 @@ class ArniRobot:
|
|
|
|
|
|
|
|
|
|
|
|
def right(self):
|
|
|
|
def right(self):
|
|
|
|
"""Hard turn right."""
|
|
|
|
"""Hard turn right."""
|
|
|
|
return self._uart.write('v 0 0 0\nv 1 -{0} 0\n'.format(self._vel))
|
|
|
|
return self._uart.write('v 0 {0} 0\nv 1 -{1} 0\n'.format(self._vel/8,self._vel))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def right_spin(self):
|
|
|
|
|
|
|
|
"""Spins clockwise in place."""
|
|
|
|
|
|
|
|
return self._uart.write('v 0 -{0} 0\nv 1 -{0} 0\n'.format(self._vel, self._vel))
|
|
|
|
|
|
|
|
|
|
|
|
def left(self):
|
|
|
|
def left(self):
|
|
|
|
"""Hard turn left."""
|
|
|
|
"""Hard turn left."""
|
|
|
|
return self._uart.write('v 0 {0} 0\nv 1 0 0\n'.format(self._vel))
|
|
|
|
return self._uart.write('v 0 {0} 0\nv 1 -{1} 0\n'.format(self._vel,self._vel/8))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def left_spin(self):
|
|
|
|
|
|
|
|
"""Spins counter-clockwise in place."""
|
|
|
|
|
|
|
|
return self._uart.write('v 0 {0} 0\nv 1 {0} 0\n'.format(self._vel, self._vel))
|
|
|
|
|
|
|
|
|
|
|
|
def right_forward(self):
|
|
|
|
def right_forward(self):
|
|
|
|
"""Right turn while moving forward."""
|
|
|
|
"""Right turn while moving forward."""
|
|
|
|