예제 #1
0
def motor(request):
    left = request.args.get('l')
    right = request.args.get('r')
    if left and not cfg.chocks:
        left = int(left)
        if left >= -100 and left <= 100:
            cfg.left_motor = int(left * cfg.left_motor_trim)
            hw.motor_two_speed(cfg.left_motor)
    if right and not cfg.chocks:
        right = int(right)
        if right >= -100 and right <= 100:
            cfg.right_motor = int(right * cfg.right_motor_trim)
            hw.motor_one_speed(cfg.right_motor)
    return response.text('ok')
예제 #2
0
def motor():
    left = request.args.get('l')
    right = request.args.get('r')
    if left and not cfg.chocks:
        left = int(left)
        if left >= -100 and left <= 100:
            cfg.left_motor = left
            hw.motor_two_speed(cfg.left_motor)
    if right and not cfg.chocks:
        right = int(right)
        if right >= -100 and right <= 100:
            cfg.right_motor = right
            hw.motor_one_speed(cfg.right_motor)
    return 'ok'
예제 #3
0
def joystick():
    cfg.watchdog = 0
    x_axis = int(request.args.get('x'))
    y_axis = int(request.args.get('y'))
    x_axis = -1 * max(min(x_axis, 100), -100)
    y_axis = max(min(y_axis, 100), -100)
    v = (100 - abs(x_axis)) * (y_axis / 100) + y_axis
    w = (100 - abs(y_axis)) * (x_axis / 100) + x_axis
    r = int((v + w) / 2)
    l = int((v - w) / 2)
    if not cfg.chocks:
        cfg.right_motor = r
        cfg.left_motor = l
        hw.motor_one_speed(cfg.right_motor)
        hw.motor_two_speed(cfg.left_motor)
    return 'ok'
예제 #4
0
def brakes_on():
    cfg.brakes = True
    cfg.left_motor = 0
    cfg.right_motor = 0
    hw.motor_one_speed(cfg.right_motor)
    hw.motor_two_speed(cfg.left_motor)
예제 #5
0
def moveRight():
    hw.motor_one_speed(100)
    hw.motor_two_speed(0)
예제 #6
0
def moveLeft():
    hw.motor_one_speed(0)
    hw.motor_two_speed(100)
예제 #7
0
def moveBackwards():
    hw.motor_one_speed(-100)
    hw.motor_two_speed(-100)
예제 #8
0
def moveForward():
    hw.motor_one_speed(100)
    hw.motor_two_speed(100)
예제 #9
0
import io_wrapper as hw
from picamera import PiCamera
from time import sleep

wheel = 0

camera = 0

if wheel == 0:
    print("Move Wheel...")
    while wheel != 1000:
        hw.motor_one_speed(-100)
        hw.motor_two_speed(-100)
        wheel = wheel + 1
        print(wheel)
        camera = PiCamera()
        camera.rotation = 180
        camera.resolution = (2592, 1944)
        camera.start_preview()
        sleep(5)
        camera.capture('/home/pi/Desktop/image.jpg')
        camera.stop_preview()

    print("Wheel Test Complete")
    hw.motor_one_speed(0)
    hw.motor_two_speed(0)
    
if camera == 0:
    print("Camera Test...")
    camera = PiCamera()
    camera.rotation = 180