Пример #1
0
 def __init__(self):
     self.Cpin1 = Pmod_IO(PMODA, 2, "out")
     self.Cpin2 = Pmod_IO(PMODA, 3, "out")
     self.Cpin3 = Pmod_IO(PMODA, 6, "out")
     self.Cpin4 = Pmod_IO(PMODA, 7, "out")
     self.sF = Sensor(0,0)
     self.sR = Sensor(1,1)
     self.sL = Sensor(4,2)
     self.pwm = Pmod_PWM(PMODB, 0)
     self.period= 20000
     self.duty= 70
Пример #2
0
 def __init__(self, R = 10, C = 10, x = 0, y = 0):
     self.SF, self.SR, self.SL = Sensor(0, 0), Sensor(1, 1), Sensor(4, 2)
     self.car = Motor()
     self.mean = 0
     self.map = [['X' for j in range(C)] for i in range(R)] # 'X' for no access; 1,2,3,etc. for path
     self.visited = [[False for j in range(C)] for i in range(R)]
     self.R, self.C = R, C
     self.current = [x, y]
     self.limit = 100
     self.junction = list()
     self.counter = 0
     self.path = list()
     self.map[x][y] = 0
     self.visited[x][y] = True
Пример #3
0

#-----------------------------------------------------


import time
import numpy as np
from pynq import Overlay
Overlay("base.bit").download()
from UltraSonic1 import Sensor
#from Motor1 import Motor

#will follow the logic of riding the right wall until it gets to the end

m = Motor()
sF = Sensor(0,0)
sR = Sensor(1,1)
sL = Sensor(4,2)

def getSurroundings():
        F = np.median([sF.getDistance() for i in range(10)])
        R = np.median([sR.getDistance() for i in range(10)])
        L = np.median([sL.getDistance() for i in range(10)])
        output = []
        output.append(int(L < 40))
        output.append(int(F < 40))
        output.append(int(R < 40))
        output.append(int(L ))
        output.append(int(F ))
        output.append(int(R ))
        return output