Ejemplo n.º 1
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
i = 3
e = 6

t_ime = time.time()
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
Ejemplo n.º 2
0
import setup
import RoboPiLib as RPL
import time

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

while True:
    if RPL.digitalRead(sensor_pin) == 1:
        import RoboPiLib as RPL
        import setup
        RPL.servoWrite(0, 2000)
        RPL.servoWrite(1, 500)

    if RPL.digitalRead(sensor_pin) == 0:
        import RoboPiLib as RPL
        import setup
        RPL.servoWrite(0, 0)
        RPL.servoWrite(1, 0)
Ejemplo n.º 3
0
def wasddrive(p1,p2,p3,p4,spd1,spd2):
   screen.addstr('')
   RPL.servoWrite(p1,spd1)
   RPL.servoWrite(p2,spd1)
   RPL.servoWrite(p3,spd2)
   RPL.servoWrite(p4,spd2)
Ejemplo n.º 4
0
def stop():
    motor_controller.stop()
    RPL.servoWrite(steering_pin, 1500)
Ejemplo n.º 5
0
def left(percent):
    RPL.servoWrite(steering_pin, -5 * percent + 1500)
Ejemplo n.º 6
0
import RoboPiLib as RPL
import sys, tty, termios, signal
motorL = 0
motorR = 1

motorR_forward = 2000
motorR_backward = 1000
motorL_forward = 1000
motorL_backward = 2000

try:
  RPL.pinMode(motorL,RPL.SERVO)
  RPL.servoWrite(motorL,1500)
  RPL.pinMode(motorR,RPL.SERVO)
  RPL.servoWrite(motorR,1500)
except:
  pass

def stopAll():
  try:
    RPL.servoWrite(motorL,1500)
    RPL.servoWrite(motorR,1500)
  except:
    print "error except"
    pass

def forward():
  RPL.servoWrite(motorL,motorL_forward)
  RPL.servoWrite(motorR,motorR_forward)

def reverse():
Ejemplo n.º 7
0
def reverse():
  RPL.servoWrite(motorL,motorL_backward)
  RPL.servoWrite(motorR,motorR_backward)
Ejemplo n.º 8
0
def small_correct():
    RPL.servoWrite(7, 1550)
    RPL.servoWrite(6, 1420)
    print "RIGHT correction"
Ejemplo n.º 9
0
def large_correct():
    RPL.servoWrite(6, 1460)
    RPL.servoWrite(7, 1570)
    print "LEFT correction"
Ejemplo n.º 10
0
def start_right():
    RPL.servoWrite(7, 1550)
    RPL.servoWrite(6, 1420)
    print "Turning Right"
Ejemplo n.º 11
0
def start_left():
    RPL.servoWrite(6, 1460)
    RPL.servoWrite(7, 1550)
    print "Turning Left"
Ejemplo n.º 12
0
def stop():
    RPL.servoWrite(6, 0)
    RPL.servoWrite(7, 0)
    print "stop"
Ejemplo n.º 13
0
import RoboPiLib as RPL
import time
import post_to_web as PTW
RPL.RoboPiInit("/dev/ttyAMA0", 115200)

i = 3


def forward():
    RPL.servoWrite(6, 1400)
    RPL.servoWrite(7, 1600)
    print "Forward"


def stop():
    RPL.servoWrite(6, 0)
    RPL.servoWrite(7, 0)
    print "stop"


def start_right():
    RPL.servoWrite(7, 1550)
    RPL.servoWrite(6, 1420)
    print "Turning Right"


def start_left():
    RPL.servoWrite(6, 1460)
    RPL.servoWrite(7, 1550)
    print "Turning Left"
Ejemplo n.º 14
0
import RoboPiLib as RPL
from setup import RPL
import post_to_web as PTW
RPL.RoboPiInit("/dev/ttyAMA0", 115200)

print "Please type in the speed you want your motors to be at:"
NumberL = int(raw_input("Left Motor > "))
NumberR = int(raw_input("Right Motor > "))

RPL.servoWrite(6, NumberR)
RPL.servoWrite(7, NumberL)
Ejemplo n.º 15
0
import setup
import RoboPiLib as RPL

#tunes the motres

falala = 2
lala = 0
toodledoo = 100
dingywink = 2000

RPL.servoWrite(lala, dingywink)
RPL.servoWrite(falala, toodledoo)

while True:
    while raw_input("> ") == "a":
        RPL.servoWrite(lala, toodledoo)
        RPL.servoWrite(falala, dingywink)
        print "fast"
    while raw_input("> ") == "b":
        RPL.servoWrite(lala, 600)
        RPL.servoWrite(falala, 1500)
        print "slow"
    while raw_input("> ") == "c":
        RPL.servoWrite(lala, 700)
        RPL.servoWrite(falala, 1400)
        print "slow backwards"
    while raw_input("> ") == "d":
        RPL.servoWrite(lala, 1000)
        RPL.servoWrite(falala, 1000)
        print "fast backwards"
    while raw_input("> ") == "q":
Ejemplo n.º 16
0
def forward():
    RPL.servoWrite(6, 1400)
    RPL.servoWrite(7, 1600)
    print "Forward"
Ejemplo n.º 17
0
now = time.time()
future = now

motorR = 2
motorL = 0
# lsens = 23
# fsens = 16

# motorR forward = 1000
# motorL forward = 2000

# Okay so this is good but I think we need to do a thing to actually make it...
# ...turn into a gap because right now it's just turning away from a wall

RPL.servoWrite(motorR, 100)
RPL.servoWrite(motorL, 2000)
print "going"
while True:
    if RPL.digitalRead(23) == 0:
        RPL.servoWrite(motorR, 100)
        RPL.servoWrite(motorL, 2000)
        print "something"
    if RPL.digitalRead(23) == 1:
        timeb = time.time()
        RPL.servoWrite(motorR, 100)
        RPL.servoWrite(motorL, 2000)
        print "gap"
        if RPL.digitalRead(23) == 0:
            timea = time.time()
            timeg = timea - timeb
Ejemplo n.º 18
0
def straight():
    RPL.servoWrite(3, 1150)
Ejemplo n.º 19
0
def forward():
  RPL.servoWrite(motorL,motorL_forward)
  RPL.servoWrite(motorR,motorR_forward)
Ejemplo n.º 20
0
def stop():
    RPL.servoWrite(0, 0)
    RPL.servoWrite(1, 0)
Ejemplo n.º 21
0
import RoboPiLib as RPL
import sys, tty, termios, signal, setup, time
from cytron import Cytron

motor_controller = Cytron(max_pwm=20000, percent_power=10, m1_pwm=0, m1_dir=1)
motor = motor_controller.m1

RPL.pinMode(motor_controller.m1["pwm"], RPL.PWM)
RPL.pinMode(motor_controller.m1["dir"], RPL.OUTPUT)

steering_pin = 3
pwm_percent = 50
print("initialized Motor Speed at {}/{} : {}%".format(
    (motor_controller.max_freq * pwm_percent) / 100, motor_controller.max_freq,
    pwm_percent))

fd = sys.stdin.fileno()
old_settings = termios.tcgetattr(fd)


def interrupted(signum, frame):
    stop()


def stop():
    motor_controller.stop()
    RPL.servoWrite(steering_pin, 1500)


def right(percent):
    RPL.servoWrite(steering_pin, 5 * percent + 1500)
Ejemplo n.º 22
0
def forward():
    RPL.servoWrite(0, 1550)
    RPL.servoWrite(1, 1450)
Ejemplo n.º 23
0
def right(percent):
    RPL.servoWrite(steering_pin, 5 * percent + 1500)
Ejemplo n.º 24
0
def backward():
    RPL.servoWrite(0, 1450)
    RPL.servoWrite(1, 1550)
Ejemplo n.º 25
0
import RoboPiLib as RPL
import setup
x = [0, 1]
for off in x:
    RPL.servoWrite(off, 1500)
    print('pin %s is disabled' % (off))
Ejemplo n.º 26
0
def left():
    RPL.servoWrite(3, 900)
Ejemplo n.º 27
0
#----SYNkeyRONIZES MOTORS

#--STANDARD

#JOINT 1
aj1 = int(1000)
#JOINT 2
aj2 = int(1000)
#JOINT 3
aj3 = int(1000)
#ACTUATOR
aac = int(1000)

#--CONTINUOUS ROTATION
RPL.servoWrite(a,crstop)
RPL.servoWrite(b,crstop)
RPL.servoWrite(c,crstop)
RPL.servoWrite(d,crstop)
print "synkeyronized"

################################################
################## FUNCTION ####################
################################################

#STANDARD SERVOS
def regulate(pin):
 if pin > 3000:
   pin = 3000
 if pin < 0:
   pin = 10
Ejemplo n.º 28
0
def right():
    RPL.servoWrite(3, 1300)
Ejemplo n.º 29
0
def stopall():
 RPL.servoWrite(a,1500)
 RPL.servoWrite(b,1500)
 RPL.servoWrite(c,1500)
 RPL.servoWrite(d,1500)
 RPL.servoWrite(i,0)
 RPL.servoWrite(j,0)
Ejemplo n.º 30
0
def Bforward_right():
    RPL.servoWrite(BmotorL, BmotorL_forward)
    RPL.servoWrite(BmotorR, 1500)