Ejemplo n.º 1
0
import brickpi
from BrickPi.Utility import Car

interface=brickpi.Interface()
interface.initialize()
Robot = Car(interface)
for i in range(4):
    Robot.moveForward(40)
    Robot.moveLeft(90)
interface.terminate()

Ejemplo n.º 2
0
import brickpi
import time
import sys
from BrickPi.Utility import Car
import newFile
import random
interface=brickpi.Interface()
interface.initialize()
sonar_port = None
touch_port = None
Robot = Car(interface)
distance = 10
newFile.DrawLines()
e = 0
f = 0
numberOfParticles = 100
particles = [(0, 0, 0) for i in range(numberOfParticles)]
print "drawParticles:" + str(particles)
angle = 90
for i in range(4):
    for j in range(4):
        Robot.moveForward(distance)
        particles = [
            (newFile.Forward(particles[i][0], particles[i][1], particles[i][2], distance, random.gauss(0, 3),
                             random.gauss(0, 2))) for i in range(numberOfParticles)]
        print "drawParticles:" + str(particles)
        time.sleep(0.5)
    Robot.moveright(angle)
    particles = [(newFile.Rotate(particles[i][0], particles[i][1], particles[i][2], angle, random.gauss(0, 2)))
                 for i in range(numberOfParticles)]
    print "drawParticles:" + str(particles)
Ejemplo n.º 3
0
import brickpi
import time
import math
from BrickPi.Utility import Car


def fun(mode):

    return


interface = brickpi.Interface()
interface.initialize()
Robot = Car(interface)
mode = int(
    input(
        "Which parameter you want to tune?\nType 1 for Kp, 2 for Ki, 3 for Kd")
)
min = int(input("Enter minimum:"))
max = int(input("ENter maximum:"))
increment = int(input("Enter incremental value:"))
dict = {'min': min, 'max': max, 'increment': increment, 'mode': mode}

input_angle = float(input("Enter a angle to rotate (in degree): "))

with open("logs/logs_name.txt", "w") as f:
    for i in range(min, max, increment, input_angle):
        if dict['mode'] == 1:
            Robot.motorParams["Left"].pidParameters.k_p = i
            Robot.motorParams["Right"].pidParameters.k_p = i
            Robot.interface.setMotorAngleControllerParameters(
Ejemplo n.º 4
0
import brickpi
import time
import sys
from BrickPi.Utility import Car
import newFile
import random
interface = brickpi.Interface()
interface.initialize()
sonar_port = None
touch_port = None
Robot = Car(interface, config_file='carpet_params.json')
distance = 10
newFile.DrawLines()
e = 0
f = 0
numberOfParticles = 100
particles = [(0, 0, 0) for i in range(numberOfParticles)]
print "drawParticles:" + str(particles)
angle = 90
for i in range(4):
    for j in range(4):
        Robot.moveForward(distance)
        particles = [(newFile.Forward(particles[i][0], particles[i][1],
                                      particles[i][2], distance,
                                      random.gauss(0, 3), random.gauss(0, 2)))
                     for i in range(numberOfParticles)]
        print "drawParticles:" + str(particles)
        time.sleep(0.5)
    Robot.moveright(angle)
    particles = [(newFile.Rotate(particles[i][0], particles[i][1],
                                 particles[i][2], angle, random.gauss(0, 2)))
Ejemplo n.º 5
0
import threading
import time
import sys
from BrickPi.Utility import Car
import BrickPi

interface = brickpi.Interface()
interface.initialize()
interface.startLogging("motor_position_1.log")

Robot = Car(interface, config_file='carpet_params.json')

# Robot.rotate_ultrasonic_motor(float(sys.argv[1]))
Robot.set_ultra_pose(float(sys.argv[1]))

interface.stopLogging()
interface.terminate()
Ejemplo n.º 6
0
import brickpi
from BrickPi.Utility import Car

interface=brickpi.Interface()
interface.initialize()
Robot = Car(interface,config_file='carpet_params.json')
for i in range(4):
    Robot.moveForward(40)
    Robot.moveLeft(90)
interface.terminate()

Ejemplo n.º 7
0
import brickpi
import time
from BrickPi.Utility import Car
interface = brickpi.Interface()
interface.initialize()

Robot = Car(interface)

Robot.moveForward(6)

print "Press Ctrl+C to exit"
while True:
    time.sleep(1)

interface.terminate()