Esempio n. 1
0
def set_motors(left, right):
    msg = motor_t()
    msg.timestamp = int(time.time())
    msg.leftmotor = left
    msg.rightmotor = right
    lc.publish("BUTTERBOT_MOTOR", msg.encode())
Esempio n. 2
0
while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit(); #sys.exit() if sys is imported
        if event.type == pygame.KEYDOWN or event.type == pygame.KEYUP:
            state = 0
            if event.type == pygame.KEYDOWN: state = 1

            if event.key == pygame.K_UP:
                spd = 70*state
            if event.key == pygame.K_DOWN:
                spd = -70*state
            if event.key == pygame.K_LEFT:
                direction = 50*state
            if event.key == pygame.K_RIGHT:
                direction = -50*state

            leftMotor = spd + direction
            rightMotor = spd - direction
            print("rightmotor: %d,  leftmotor: %d" % (leftMotor, rightMotor))

    msg = motor_t()
    msg.timestamp = int(time.time())
    msg.leftmotor = leftMotor
    msg.rightmotor = rightMotor
    lc.publish("BUTTERBOT_MOTOR", msg.encode())
    time.sleep(.5)
            

Esempio n. 3
0
rightMotor = 0

while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            #sys.exit() if sys is imported
        if event.type == pygame.KEYDOWN or event.type == pygame.KEYUP:
            state = 0
            if event.type == pygame.KEYDOWN: state = 1

            if event.key == pygame.K_UP:
                spd = 70 * state
            if event.key == pygame.K_DOWN:
                spd = -70 * state
            if event.key == pygame.K_LEFT:
                direction = 50 * state
            if event.key == pygame.K_RIGHT:
                direction = -50 * state

            leftMotor = spd + direction
            rightMotor = spd - direction
            print("rightmotor: %d,  leftmotor: %d" % (leftMotor, rightMotor))

    msg = motor_t()
    msg.timestamp = int(time.time())
    msg.leftmotor = leftMotor
    msg.rightmotor = rightMotor
    lc.publish("BUTTERBOT_MOTOR", msg.encode())
    time.sleep(.5)
Esempio n. 4
0
def set_motors(left, right):
    msg = motor_t()
    msg.timestamp = int(time.time())
    msg.leftmotor = left
    msg.rightmotor = right
    lc.publish("BUTTERBOT_MOTOR", msg.encode())