Exemplo n.º 1
0
#!/usr/bin/env python
# -*- coding: utf-8 


import struct, time
import kbhit
from RobotCommunication import SerialCommands

robot = SerialCommands('/dev/ttyAMA0',115200)
kb = kbhit.KBHit()

print robot.init()



if __name__ == '__main__':
	
	robot.startLineFollowing(20) ###start line following with speed 1-127
	
	
	while 1: 
		
		if kb.kbhit():  ### check if the key is pressed
			key = kb.getch()
			if key == 'r':   ##if pressed "r" go from left to right lane
				robot.laneChange(1)
			if key == 'l':   ##if pressed "l" go from right to left lane
				robot.laneChange(-1)
			if key == 's': ## if pressed "s" stop the robot
				robot.init()
Exemplo n.º 2
0
from picamera import PiCamera

import time
import cv2
import numpy as np
from RobotCommunication import SerialCommands

import socket

host = '192.168.30.37'  ###address of the server
port = 9092

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((host, port))

robot = SerialCommands('/dev/ttyAMA0', 115200)
print robot.init()

# initialize the camera and grab a reference to the raw camera capture
camera = PiCamera()
camera.resolution = (640, 480)
rawCapture = PiRGBArray(camera, size=(640, 480))

# allow the camera to warmup
time.sleep(0.1)


def findDist():
    camera.capture(rawCapture, format="bgr")
    img = rawCapture.array  #take image
Exemplo n.º 3
0
import numpy as np
from RobotCommunication import SerialCommands

import socket
import scipy.integrate

cruise_dist = 300
v_desr = 100

host = '192.168.30.37'  ###address of the server
port = 9092

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((host, port))

robot = SerialCommands('/dev/ttyAMA0', 115200)
print robot.init()

# initialize the camera and grab a reference to the raw camera capture
camera = PiCamera()
camera.resolution = (640, 480)
rawCapture = PiRGBArray(camera, size=(640, 480))

# allow the camera to warmup
time.sleep(0.1)


def findDist():
    camera.capture(rawCapture, format="bgr")
    img = rawCapture.array  #take image
Exemplo n.º 4
0
from GPSServerConnection import GPSServerConnection
from RobotCommunication import SerialCommands
import numpy as np

import time

gps_pos = GPSServerConnection()
robot = SerialCommands('/dev/ttyAMA0',115200)

pos_x=[]
pos_y=[]

if __name__ == '__main__':
		
	pos,t = gps_pos.getPosition(1)
	pos_x.append(pos[0])
	pos_y.append(pos[1])
	
	robot.startLineFollowing(20)

	
	for i in range(1,40):
		
		pos_x.append(pos_x[i-1]+ (20*0.465*0.2)*0.2516)
		pos_y.append(pos_y[i-1])

		
		time.sleep(0.2)
		
	print pos_x[39]
	
Exemplo n.º 5
0
import sys
sys.path.append('/usr/local/lib/python2.7/site-packages')


from picamera.array import PiRGBArray
from picamera import PiCamera

from oct2py import octave
#octave.addpath('./for_octave/image_matlab')
import time
import cv2

import struct, time
from RobotCommunication import SerialCommands

robot = SerialCommands('/dev/ttyAMA0',115200)
print robot.init()

# initialize the camera and grab a reference to the raw camera capture
camera = PiCamera()
camera.resolution = (640, 480)
rawCapture = PiRGBArray(camera, size=(640, 480))

cruise_distance = 200 ## in mm
v_max = 80 ## in mm/s
v_curr = 1
a_max = 2

# allow the camera to warmup
time.sleep(0.1)
Exemplo n.º 6
0
from RobotCommunication import SerialCommands
import time

dist = int(raw_input('set distance/n'))
robot = SerialCommands('/dev/ttyAMA0', 115200)
#robot.resetEncoders()
#old = robot.readEncoders()
#print old
#robot.autoCalibrate()
#time.sleep(5)
print robot.init()
robot.fixedDistance(dist)
#robot.startLineFollowing(40)
Exemplo n.º 7
0
from RobotCommunication import SerialCommands
import time

dist = int(raw_input('set distance/n'))
robot = SerialCommands('/dev/ttyAMA0',115200)
#robot.resetEncoders()
#old = robot.readEncoders()
#print old
#robot.autoCalibrate()
#time.sleep(5)
print robot.init()
robot.fixedDistance(dist)
#robot.startLineFollowing(40)



Exemplo n.º 8
0
import numpy as np
from RobotCommunication import SerialCommands

import socket
import scipy.integrate

cruise_dist =300
v_desr = 100

host = '192.168.30.37'   ###address of the server
port = 9092

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((host , port))

robot = SerialCommands('/dev/ttyAMA0',115200)
print robot.init()

# initialize the camera and grab a reference to the raw camera capture
camera = PiCamera()
camera.resolution = (640, 480)
rawCapture = PiRGBArray(camera, size=(640, 480))

# allow the camera to warmup
time.sleep(0.1)
    

def findDist():
    camera.capture(rawCapture, format="bgr")
    img = rawCapture.array               #take image
    
Exemplo n.º 9
0
from GPSServerConnection import GPSServerConnection
from RobotCommunication import SerialCommands
import numpy as np

import time

gps_pos = GPSServerConnection()
robot = SerialCommands('/dev/ttyAMA0', 115200)

pos_x = []
pos_y = []

if __name__ == '__main__':

    pos, t = gps_pos.getPosition(1)
    pos_x.append(pos[0])
    pos_y.append(pos[1])

    robot.startLineFollowing(20)

    for i in range(1, 40):

        pos_x.append(pos_x[i - 1] + (20 * 0.465 * 0.2) * 0.2516)
        pos_y.append(pos_y[i - 1])

        time.sleep(0.2)

    print pos_x[39]

    robot.init()
    print gps_pos.getPosition(1)
Exemplo n.º 10
0
from picamera import PiCamera

import time
import cv2
import numpy as np
from RobotCommunication import SerialCommands

import socket

host = '192.168.30.37'   ###address of the server
port = 9092

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((host , port))

robot = SerialCommands('/dev/ttyAMA0',115200)
print robot.init()

# initialize the camera and grab a reference to the raw camera capture
camera = PiCamera()
camera.resolution = (640, 480)
rawCapture = PiRGBArray(camera, size=(640, 480))

# allow the camera to warmup
time.sleep(0.1)
    

def findDist():
    camera.capture(rawCapture, format="bgr")
    img = rawCapture.array               #take image