Esempio n. 1
0

def reverse():
    RPL.servoWrite(motorL, motorL_backward)
    RPL.servoWrite(motorR, motorR_backward)


def stop():
    RPL.servoWrite(motorL, 0)
    RPL.servoWrite(motorR, 0)


while counter == 0:
    RPL.analogRead(0)
    RPL.analogRead(3)
    Fanalog = RPL.analogRead(0)
    Banalog = RPL.analogRead(3)

    straight = Fanalog - Banalog

    if straight > -2 and straight < 8:
        reverse()
#if the robot is angled away the wall- turn tiwards
    if straight < -2:
        RPL.servoWrite(motorL, 1550)
        RPL.servoWrite(motorR, motorR_backward)
#if the robot is towards  the wall
    if straight > 8:
        RPL.servoWrite(motorL, motorL_backward)
        RPL.servoWrite(motorR, 1450)
Esempio n. 2
0
def front(input):
    RPL.servoWrite(R, convert(input)[0])
    RPL.servoWrite(L, convert(input)[1])
Esempio n. 3
0
def right(input):
    RPL.servoWrite(L, convert(input)[1])
Esempio n. 4
0
def reverse():
    RPL.servoWrite(1, 1600)
    RPL.servoWrite(2, 1400)
    print "stop"
Esempio n. 5
0
def start_left():
    RPL.servoWrite(1, 1460)
    RPL.servoWrite(2, 1550)
    print "Turning Left"
Esempio n. 6
0
def leftStop():
    RPL.servoWrite(L, 1500)
Esempio n. 7
0
import RoboPiLib as RPL
import time

RPL.RoboPiInit("/dev/ttyAMA0", 115200)

analogSensor = 10
motorR = 1
motorL = 0
speed = 1400

while True:
    reading == RPL.analogReadRaw(analogSensor)
    if reading > 400:
        speed -= 100
        if speed < 0:
            speed = 0
        else:
            speed = speed
        RPL.servoWrite(motorR, speed)
        RPL.servoWrite(motorL, speed + 1400)
        time.sleep(0.1)
    else:
        RPL.servoWrtie(motorR, 1400)
        RPL.servoWrite(motorL, 2900)
Esempio n. 8
0
def retract():
    RPL.servoWrite(foot_down, 0)
    RPL.servoWrite(foot_up, 20000)
Esempio n. 9
0
def Rmin(go):
    future = go + 1
    while go < future:
        RPL.servoWrite(motorL, rgo)
        RPL.servoWrite(motorR, rgo)

def Lmin(go):
    future = go + 1
    while go < future:
        RPL.servoWrite(motorL, lgo)
        RPL.servoWrite(motorR, lgo)

# next step! add in minimum turning time of ~= 1 second

RPL.servoWrite(motorR, rgo)
RPL.servoWrite(motorR, rgo)
RPL.servoWrite(motorL, lgo)
RPL.servoWrite(motorL, lgo)
while True:
    RPL.servoWrite(motorR, rgo)
    RPL.servoWrite(motorL, lgo)
    print ".............."

    while RPL.digitalRead(front) == 0 and RPL.digitalRead(right) == 0: # reverse
        if RPL.digitalRead(left) == 0:
            RPL.servoWrite(motorR, lgo)
            RPL.servoWrite(motorL, rgo)


    while RPL.digitalRead(front) == 0: # something ahead, turn until nothing
Esempio n. 10
0
now = time.time()
future = now

motorL = 0
motorR = 2

right = 17
front = 16
left = 19

rgo = 2000
rslow = 1500
lgo = 100
lslow = 600

RPL.servoWrite(motorR, rgo)
RPL.servoWrite(motorR, rgo)
RPL.servoWrite(motorL, lgo)
RPL.servoWrite(motorL, lgo)

while True:
    RPL.servoWrite(motorR, rgo)
    RPL.servoWrite(motorL, lgo)

    while RPL.analogRead(analogR) >= 300:  # middle range, can go straight
        print "we good"
        RPL.servoWrite(motorR, rgo)
        RPL.servoWrite(motorL, lgo)

    while RPL.analogRead(analogR) < 300:  # no longer middle
        while RPL.digitalRead(19) == 0:  # digital also sense, so close
Esempio n. 11
0
def extend():
    RPL.servoWrite(foot_up, 0)
    RPL.servoWrite(foot_down, 20000)
Esempio n. 12
0
def stop():
    RPL.servoWrite(motorL, 0)
    RPL.servoWrite(motorR, 0)
Esempio n. 13
0
def reverse():
    RPL.servoWrite(motorL, motorL_backward)
    RPL.servoWrite(motorR, motorR_backward)
Esempio n. 14
0
def forward():
    RPL.servoWrite(motorL, motorL_forward)
    RPL.servoWrite(motorR, motorR_forward)
Esempio n. 15
0
def leftGo():
    RPL.servoWrite(L, 1400)
Esempio n. 16
0
def Rmin(go):
    future = go + 1
    while go < future:
        RPL.servoWrite(motorL, rgo)
        RPL.servoWrite(motorR, rgo)
Esempio n. 17
0
def rightGo():
    RPL.servoWrite(R, 1600)
Esempio n. 18
0
def Lmin(go):
    future = go + 1
    while go < future:
        RPL.servoWrite(motorL, lgo)
        RPL.servoWrite(motorR, lgo)
Esempio n. 19
0
def rightStop():
    RPL.servoWrite(R, 1500)
Esempio n. 20
0
import RoboPiLib as RPL
import setup

motorL = 1
motorR = 0

RPL.servoWrite(1, 2000)
RPL.servoWrite(0, 2000)
time.time(.5)
Esempio n. 21
0
import post_to_web as PTW

sensor_pin = 16
RPL.pinMode(sensor_pin, RPL.INPUT)

running = True
braking = False
m1Speed = 1400
m2Speed = 1600
while running:
    reading = RPL.digitalRead(sensor_pin)

    if reading == 0:
        braking = True
    if braking == True and m1Speed != 1500 and m2Speed != 1500:
        print("If statement fired")
        m1Speed += 10
        m2Speed -= 10
    if m1Speed == 1500 and m2Speed == 1500:
        m1Speed = 00
        m2Speed = 00
        running = False

    RPL.servoWrite(0, m1Speed)
    RPL.servoWrite(1, m2Speed)

    PTW.state['d1'] = RPL.digitalRead(sensor_pin)
    PTW.state['d2'] = RPL.servoRead(0)
    PTW.state['d3'] = RPL.servoRead(1)
    PTW.post()
Esempio n. 22
0
import time
import RoboPiLib as RPL
import setup

pwm_freq = 0
pwm_pin = int(raw_input("PWM Pin:  "))
step = int(raw_input("PWM Step: "))

try:
    while True:
        RPL.servoWrite(pwm_pin, pwm_freq)
        print("PWM Frequency at {}".format(pwm_freq))
        time.sleep(0.5)
        pwm_freq += step
except:
    RPL.servoWrite(pwm_pin, 0)
    print("Finished at {}".format(pwm_freq))
Esempio n. 23
0
def start_right():
    RPL.servoWrite(2, 1550)
    RPL.servoWrite(1, 1420)
    print "Turning Right"
Esempio n. 24
0
import RoboPiLib as RPL
import setup
RPL.servoWrite(0, 00)
RPL.servoWrite(1, 00)
Esempio n. 25
0
def forward():
    RPL.servoWrite(1, 1400)
    RPL.servoWrite(2, 1600)
    print "Forward"
Esempio n. 26
0
import RoboPiLib as RPL
RPL.RoboPiInit("/dev/ttyAMA0", 115200)

RPL.servoWrite(1, 1000)
RPL.servoWrite(2, 2000)
"""

ssh [email protected]

"""
Esempio n. 27
0
def left(input):
    RPL.servoWrite(R, convert(input)[0])
Esempio n. 28
0
def forward():
    RPL.servoWrite(6, 1400)
    RPL.servoWrite(7, 1600)
    print "Forward"
Esempio n. 29
0
def frontraw(input):
    RPL.servoWrite(L, input)
    RPL.servoWrite(R, -1 * input + 3000)
Esempio n. 30
0
import RoboPiLib as RPL
from setup import RPL
import time
import post_to_web as PTW
RPL.RoboPiInit("/dev/ttyAMA0", 115200)

motorL = 1
motorR = 0
t_ime = time.time()
i = 3
e = 6

while True:
    while time.time() < t_ime + i:
        RPL.servoWrite(motorR, 1000)
        RPL.servoWrite(motorL, 2000)
    while time.time() > t_ime + i and time.time() < t_ime + e:
        RPL.servoWrite(motorR, 0)
        RPL.servoWrite(motorL, 0)
    while time.time() > t_ime + e:
        i = i + 3
        e = e + 3