How to use the motor.Packet function in motor

To help you get started, we’ve selected a few motor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mattjml / pi_cam_line_follower / motor.py View on Github external
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)
github mattjml / pi_cam_line_follower / motor.py View on Github external
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)
github mattjml / pi_cam_line_follower / motor.py View on Github external
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)
github mattjml / pi_cam_line_follower / motor.py View on Github external
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)
github mattjml / pi_cam_line_follower / motor.py View on Github external
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)