Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def specific_move(self, dir_left, steps_left, speed_left, dir_right, steps_right, speed_right):
l_packet = Packet(control=[Packet.CONTROL_LEFT_FORWARD, Packet.CONTROL_LEFT_BACKWARD][dir_left == Motion.BACKWARD],
speed = speed_left >> 1,
steps = steps_left >> 1)
r_packet = Packet(control=[Packet.CONTROL_RIGHT_FORWARD, Packet.CONTROL_RIGHT_BACKWARD][dir_right == Motion.BACKWARD],
speed = speed_right >> 1,
steps = steps_right >> 1)
self.comms.write(l_packet.bytes)
self.comms.write(r_packet.bytes)
def _linear_move(self, direction, steps, speed):
assert direction == Motion.FORWARD or direction == Motion.BACKWARD
assert steps >= 0
l_packet = Packet(control=[Packet.CONTROL_LEFT_FORWARD, Packet.CONTROL_LEFT_BACKWARD][direction == Motion.BACKWARD],
speed = speed >> 1,
steps = steps >> 1)
r_packet = Packet(control=[Packet.CONTROL_RIGHT_FORWARD, Packet.CONTROL_RIGHT_BACKWARD][direction == Motion.BACKWARD],
speed = speed >> 1,
steps = steps >> 1)
self.comms.write(l_packet.bytes)
self.comms.write(r_packet.bytes)
def _linear_move(self, direction, steps, speed):
assert direction == Motion.FORWARD or direction == Motion.BACKWARD
assert steps >= 0
l_packet = Packet(control=[Packet.CONTROL_LEFT_FORWARD, Packet.CONTROL_LEFT_BACKWARD][direction == Motion.BACKWARD],
speed = speed >> 1,
steps = steps >> 1)
r_packet = Packet(control=[Packet.CONTROL_RIGHT_FORWARD, Packet.CONTROL_RIGHT_BACKWARD][direction == Motion.BACKWARD],
speed = speed >> 1,
steps = steps >> 1)
self.comms.write(l_packet.bytes)
self.comms.write(r_packet.bytes)
def _rotate_move(self, direction, steps, speed):
assert direction == Motion.LEFT or direction == Motion.RIGHT
assert steps >= 0
l_packet = Packet(control=[Packet.CONTROL_LEFT_FORWARD, Packet.CONTROL_LEFT_BACKWARD][direction == Motion.LEFT],
speed = speed >> 1,
steps = steps >> 1)
r_packet = Packet(control=[Packet.CONTROL_RIGHT_FORWARD, Packet.CONTROL_RIGHT_BACKWARD][direction == Motion.RIGHT],
speed = speed >> 1,
steps = steps >> 1)
self.comms.write(r_packet.bytes)
self.comms.write(l_packet.bytes)
def _rotate_move(self, direction, steps, speed):
assert direction == Motion.LEFT or direction == Motion.RIGHT
assert steps >= 0
l_packet = Packet(control=[Packet.CONTROL_LEFT_FORWARD, Packet.CONTROL_LEFT_BACKWARD][direction == Motion.LEFT],
speed = speed >> 1,
steps = steps >> 1)
r_packet = Packet(control=[Packet.CONTROL_RIGHT_FORWARD, Packet.CONTROL_RIGHT_BACKWARD][direction == Motion.RIGHT],
speed = speed >> 1,
steps = steps >> 1)
self.comms.write(r_packet.bytes)
self.comms.write(l_packet.bytes)