Beispiel #1
0
def steer(prediction):
    dist = us1.distance()
    print(dist)
    if prediction == 1 and dist > 40:
        print('forward')
        g.forwardGPIO()
    elif dist < 40 and prediction == 1:
        print('too close! going away')
        g.reverseGPIO(1.6)
        time.sleep(0.1)
        g.leftGPIO()
    elif prediction == 0 and dist > 40:
        print('left')
        g.leftGPIO()
    elif dist < 40 and prediction == 0:
        print('nope! going right!')
        g.reverseGPIO(1.6)
        time.sleep(0.1)
        g.rightGPIO()
    elif prediction == 2 and dist > 40:
        print('right')
        g.rightGPIO()
    elif dist < 40 and prediction == 2:
        print('nope! going left')
        g.reverseGPIO(1.6)
        time.slee(0.1)
        g.leftGPIO()
    else:
        print('Take care of me please :)')
        g.stopGPIO()
Beispiel #2
0
    def steer(prediction):
        dist = us1.distance()
        print(dist)
        if prediction == 1 and dist > 40:
            print('forward')
            g.forwardGPIO()
        elif dist < 40 and prediction == 1:
            print('too close! waiting for 2 seconds')
            g.stopGPIO()
            time.sleep(2)
            g.reverseGPIO(0.8)
            time.sleep(0.1)

        elif prediction == 0 and dist > 40:
            print('left')
            g.leftGPIO()
        elif dist < 40 and prediction == 0:
            print('Too close! waiting for 2 seconds')
            g.stopGPIO()
            time.sleep(2)
            g.reverseGPIO(0.8)

        elif prediction == 2 and dist > 40:
            print('right')
            g.rightGPIO()
        elif dist < 40 and prediction == 2:
            print('Too close! waiting for 2 seconds')
            g.stopGPIO()
            time.sleep(2)
            g.reverseGPIO(0.8)

        else:
            print('Take care of me please :)')
            g.stopGPIO()
Beispiel #3
0
def reroute(changepin):
    changePin = int(changepin)

    if changePin == 1:
        g.leftGPIO()
    elif changePin == 2:
        g.forwardGPIO()
    elif changePin == 3:
        g.rightGPIO()
    elif changePin == 4:
        g.reverseGPIO()
    else:
        g.stopGPIO()
        g.clean()
    response = make_response(redirect(url_for('index')))
    return (response)