def loadModel(self): self.prop = Cannon.Cannon(self.cr) self.prop.cannonPost = self.prop self.prop.shipId = self.shipId self.prop.doId = self.doId self.prop.reparentTo(self) self.prop.loadModel(None)
def createProp(self): cannon = self.ship.cannons.get(self.cannonIndex, 0) if cannon: if cannon[0]: self.prop = cannon[0] self.ship.cannons[self.cannonIndex][1] = self return self.prop = Cannon.Cannon(self.cr, True) self.ship.cannons[self.cannonIndex] = [self.prop, self]
interface = Interface(640,695,100,600,"F.I.R.E. -MAIN_AUTO(0.1) TEST-",100) interface.build() pygame.init() ############################ GPIO.setmode(GPIO.BOARD) # BOARD!!! ############################ # Initialize the devices # motorController = MotorController(12,29,31,33,35,26,100) #ENA,IN1,IN2,IN3,IN4,ENB,Velocity(from 0 to 100) ultrasoundSensorL = UltrasoundSensor(5,3) #TRIGG,ECHO ultrasoundSensorF = UltrasoundSensor(11,7) #TRIGG,ECHO ultrasoundSensorR = UltrasoundSensor(15,13) #TRIGG,ECHO view = View(23,21) #LRServo,UDServo [servoLR = ServoMotor(23)YELLOW, servoUD = ServoMotor(21)YELLOW] tempHumL = TempHumSensor(8) #DATA tempHumR = TempHumSensor(10) #DATA irSensor = IRSensor(19) #DATA cannon = Cannon(37) webcam = WebCam() ############################ #-#-# MAIN LOOP #-#-# textMov = 'MOVING: STOP' textView = 'VIEW: CENTER' textCannon = 'CANNON: STOPPED' textTempL = '_' textTempR = '_' textDistL = '_' textDistF = '_' textDistR = '_' run = True motorController.initialize() ultrasoundSensorL.initialize()
timeslice = 0.05 # How many seconds should elapse per iteration? iterations = 288 # How many iterations should the simulation run for? # (notice that the full journey takes 14.416 seconds, so 145 iterations will # cover the whole thing when timeslice = 0.10) noiselevel = 30 # How much noise should we add to the noisy measurements? # These are arrays to store the data points we want to plot at the end. x = [] y = [] nx = [] ny = [] vx = [] vy = [] # Let's make a cannon simulation. c = Cannon(timeslice, noiselevel) for i in range(iterations): x.append(c.GetX()) y.append(c.GetY()) newestX = c.GetXWithNoise() newestY = c.GetYWithNoise() nx.append(newestX) ny.append(newestY) # Iterate the cannon simulation to the next timeslice. c.Step() vx.append(c.GetXVelocity()) vy.append(c.GetYVelocity()) # Plot all the results we got. pylab.plot(x, y, '-', nx, ny, ':')
GPIO.setmode(GPIO.BOARD) # BOARD!!! ############################ # Initialize the devices # motorController = MotorController( 12, 29, 31, 33, 35, 26, 100) #ENA,IN1,IN2,IN3,IN4,ENB,Velocity(from 0 to 100) ultrasoundSensorL = UltrasoundSensor(5, 3) #TRIGG,ECHO ultrasoundSensorF = UltrasoundSensor(11, 7) #TRIGG,ECHO ultrasoundSensorR = UltrasoundSensor(15, 13) #TRIGG,ECHO view = View( 23, 21 ) #LRServo,UDServo [servoLR = ServoMotor(23)YELLOW, servoUD = ServoMotor(21)YELLOW] tempHumL = TempHumSensor(8) #DATA tempHumR = TempHumSensor(10) #DATA infraRedSen = IRSensor(19) #DATA cannon = Cannon(37) #Transistor sign pin -> WE MUST DEFINE THIS CLASS!!!! webcam = WebCam() ############################ #-#-# MAIN LOOP #-#-# textMov = 'MOVING: STOP' textView = 'VIEW: CENTER' textCannon = 'CANNON: STOPPED' textTempL = '_' textTempR = '_' textDistL = '_' textDistF = '_' textDistR = '_' run = True motorController.initialize() ultrasoundSensorL.initialize()
def addCannon(self, pos): self.towers.append(Cannon(pos))