def __init__(self, framerate=10): """ framerate (frames per second) defines the maximum refresh rate. update will wait to maintain this rate """ self.frameRate = 10 # slow down to 10 steps per second. self.screen = gui.init_surface((800, 200), " CART +IP demo") self.frameRate = framerate
def __init__(self,framerate=10): """ framerate (frames per second) defines the maximum refresh rate. update will wait to maintain this rate """ self.frameRate=10 # slow down to 10 steps per second. self.screen = gui.init_surface((800,200)," CART +IP demo" ) self.frameRate=framerate
def __init__(self, world, title, log_file=None): #: world a World #: agents list of agents self.admin = Admin() self.ticks = 0 self.slowMotionFactor = 1.0 self.world = world w, h = (self.world.dimensions()) dim_world = (w + 20, h + 20) self.frameskipfactor = 1 self.frameskipcount = 1 self.painter = None self.screen = gui.init_surface(dim_world, title) if log_file != None: self.log_file = open(log_file, "w") self.run_name = title
def __init__(self,world,run_name,dt): #: world a World #: agents list of agents self.admin=None self.ticks=0 self.slowMotionFactor=1.0 self.world = world w,h=self.world.dimensions() dim_world = (w+20,h+20) self.frameskipfactor=1 self.frameskipcount=1 self.painter=None self.dt=dt self.screen = gui.init_surface(dim_world,run_name) self.log_file=open(run_name+".log","w") self.run_name=run_name
def __init__(self,world,title,log_file=None): #: world a World self.stopping=False self.admin=Admin() self.ticks=0 self.slowMotionFactor=1.0 self.world = world w,h=(self.world.dimensions()) dim_world = (w+20,h+20) self.frameskipfactor=1 self.frameskipcount=1 self.painter=None self.screen = gui.init_surface(dim_world,title) if log_file != None: self.log_file=open(log_file,"w") self.run_name=title
gui.blit(screen) #### MAIN CODE ######################### # create an inverted pendulum cart = cart.Cart(dt=.01) dt = .1 # set the initial angle cart.setAngle(math.pi + 0.02) frameRate = 10 # slow down to 10 steps per second. screen = gui.init_surface((800, 200), " CART + IP demo") force_scale = 10.0 sizes = [2, 1] net = brain.loadBrain() INIT_ANG = 0.3 cart.setAngle(math.pi + INIT_ANG) while not gui.check_for_quit(): # loop until user hits escape # Test for falling over # if fallen then reset with a random angle
#### MAIN CODE ######################### # create an inverted pendulum cart=cart.Cart() dt=.1 factory=Factory() pool=pool.Pool(size=40,factory=factory,breed_prob=.0,seed_prob=0.1) frameRate=10 # slow down to 10 steps per second. screen = gui.init_surface((800,200)," CART + IP demo" ) graphics=False best_fit=-1e32 tot_time=0.0 best_guess=None inc=False force_scale=10.0 sizes=[4,1] net=None TOTAL_TIME_MAX=10000
str2="" str2+= "O: %5.2f " % (state[0]) str2+= "dO/dt: %5.2f " % (state[1]) str2+= "beta: %5.2f " % (state[2]) str2+= "dbeta/dt: %5.2f " % (state[3]) str2+= " pwmRatio: %5.2f " % (pwmRatio) gui.draw_string(screen,str2,(20,10),col,16) # Copy the screen onto the display gui.blit(screen) """ MAIN CODE """ #Set GUI parameters and initialize screen frameRate = 200 #Frames per second screen = gui.init_surface((1200,800),"IP demo" ) # Create an instance of the robot, sensor filter and controller robot = robot.Robot() filter = sensFilters.CompFilter(robot) controller = controller.Controller() # Set the robot's initial tilt angle (rad) robot.setAngle(0.7) while not gui.check_for_quit(): # loop until user hits escape pwmRatio=0.0 tau = 0.0 #"""
str2 += "O: %5.2f " % (state[0]) str2 += "dO/dt: %5.2f " % (state[1]) str2 += "beta: %5.2f " % (state[2]) str2 += "dbeta/dt: %5.2f " % (state[3]) str2 += " pwmRatio: %5.2f " % (pwmRatio) gui.draw_string(screen, str2, (20, 10), col, 16) # Copy the screen onto the display gui.blit(screen) """ MAIN CODE """ #Set GUI parameters and initialize screen frameRate = 200 #Frames per second screen = gui.init_surface((1200, 800), "IP demo") # Create an instance of the robot, sensor filter and controller robot = robot.Robot() filter = sensFilters.CompFilter(robot) controller = controller.Controller() # Set the robot's initial tilt angle (rad) robot.setAngle(0.7) while not gui.check_for_quit(): # loop until user hits escape pwmRatio = 0.0 tau = 0.0 #"""