예제 #1
0
class DiskDriver():
    def __init__(self):
        self.myDriver = Driver()
        self.data = ''
        self.start_time = 0
        self.end_time = -1
        self.total_time = -1

    def run(self):
        colnames = [
            'STIME', 'TIME', 'UID', 'PID', 'D', 'BLOCK', 'SIZE', 'COMM',
            'PATHNAME'
        ]
        data = pandas.read_csv(self.data, names=colnames)
        data_dir = data.D.tolist()
        data_addr = map(lambda x: x * 512, data.BLOCK.tolist())
        data_size = data.SIZE.tolist()
        arrs = []
        length = len(data_dir)
        self.start_time = time.time()
        for i in range(0, length):
            self.myDriver.drive(data_dir[i], data_addr[i], data_size[i])
        self.end_time = time.time()
        self.total_time = self.end_time - self.start_time

        self.myDriver.close()

    def open(self, data, target):
        self.myDriver.open(target)
        self.data = data

    def get_time(self):
        return self.total_time
예제 #2
0
class Wrapper():

    def __init__(self):
        self.myDriver = Driver()
        self.data = ''
        self.start_time = 0
        self.end_time = -1
        self.total_time = -1

    def run(self):
        colnames = ['STIME','TIME','UID','PID','D','BLOCK','SIZE','COMM','PATHNAME']
        data = pandas.read_csv(self.data,names = colnames)
        data_dir = data.D.tolist()
        data_addr = map(lambda x: x*512, data.BLOCK.tolist())
        data_size = data.SIZE.tolist()
        arrs = []
        length = len(data_dir)
        self.start_time = time.time()
        for i in range(0,length):
            self.myDriver.drive(data_dir[i],data_addr[i],data_size[i])
        self.end_time = time.time()
        self.total_time = self.end_time - self.start_time
    
        self.myDriver.close()

    def open(self,data,target):
        self.myDriver.open(target)
        self.data = data

    def get_time(self):
        return self.total_time
예제 #3
0
try:
    """output = SplitFrames(connection)
    with picamera.PiCamera(resolution=res, framerate=32) as camera:
        time.sleep(1)
        start = time.time()
        camera.start_recording(output, format = 'mjpeg')
        time.sleep(60)
        camera.stop_recording()
    connection.write(struct.pack('<L',0))"""
    while recv_inst:
        data = command_socket.recv(53)
        print(data)
        if data != b'':
            data = pickle.loads(data)
            print(data)
            if data == 'quit':
                recv_inst = False
            else:
                t = data['throttle']
                s = data['speed']
                a = data['angle']
                drive.drive(t, s, a)
        else:
            drive.drive(0, 0, 90)

finally:
    finish = time.time()
    #connection.close()
    #client_socket.close()
    command_socket.close()
예제 #4
0
	# Read In Photo
	try:
		stream.seek(0)
		
		dh = DataHandler(initialize_files=False)
		nn = NeuralNetwork()
		nn.load()
		im = imread(stream, flatten=True)
		prediction = nn.predict([im], True)
		prediction_index = dh.determine_index(prediction)
		print("Prediction:", dh.index_to_description(prediction_index))

		# Forward
		if prediction_index==0:
			driver.drive(Direction.FORWARD, 150)
		# Right
		else if prediction_index==1:
			driver.turn(Direction.RIGHT, 255)
		# Left
		else if prediction_index==2:
			driver.turn(Direction.LEFT, 255)
		

	finally:
		# Reset the stream and event
		self.stream.seek(0)
		self.stream.truncate()


	# checks if the player hits the start key, indicating that they want to stop autonomous mode
예제 #5
0
from Driver import Driver
from Driver import Direction

import atexit

driver = Driver()

#Driving Tests

#Test drive forward. Observe to determine pass or fail.
print("Forward Test")
driver.drive(Direction.FORWARD, 100, 2)

#Test drive Backward. Observe to determine pass or fail.
print("Backward Test")
driver.drive(Direction.BACKWARD, 100, 2)

#Test left. Observe to determine pass or fail.
print("Left Test")
driver.turn(Direction.LEFT, 150)

#Test right. Observe to determine pass or fail.
print("Right Test")
driver.turn(Direction.RIGHT, 150)

#THIS NEEDS TO RUN WHEN A DRIVER IS CREATED
#What this does is makes sure that if the program is killed,
#the motors will stop and not run forever
atexit.register(driver.turnOffMotors)