, type="int" , help="Which framerate the server runs at" , default=25 ) (options, args) = parser.parse_args() (w, h) = Params.pitchSize objects = {} objects['ball'] = Ball((w/2, h/2), (0, 0)) objects['blue'] = Robot((60, h/2), (0,0), 0, "blue") objects['yellow'] = Robot((w-60, h/2), (0,0), pi, "yellow") simulation = Simulation(objects, draw=True) def goal_scored(simulation, space, arbiter, obj, goal): simulation.reset() robot_string = "Yellow" if goal == CT_LEFT_GOAL else "Blue" print "%s robot scored!" % robot_string return True simulation.addGoalCollisionFunc(goal_scored, objects['ball'], CT_LEFT_GOAL) simulation.addGoalCollisionFunc(goal_scored, objects['ball'], CT_RIGHT_GOAL) vss = VisionServerStarter(simulation, options.fps * 5) #FIXME: Multiplying by 5, because FPS is not correct - suspect that 5 clients connect vss.start(31410) csf = CommsServerFactory(simulation) csf.start() simulation.start()
#!/usr/bin/env python from Simulator.VisionWrapper import VisionWrapper from Simulator.CommsWrapper import CommsWrapper from Simulator.StrategyWrapper import StrategyWrapper from Simulator.Servers.VisionServer import VisionServerStarter from Simulator.Servers.CommsServer import CommsServerFactory from Simulator.Simulation import Simulation from Simulator.Model.WorldObjects import Robot, Ball objects = { 'blue' : Robot((0,0), (0,0), 0, "blue") , 'yellow' : Robot((0,0), (0,0), 0, "yellow") , 'ball' : Ball((0,0), (0,0)) } sim = Simulation(objects, draw=True) sim.start() try: vw = VisionWrapper(sim) except Exception, e: print "VisionWrapper Error: %s" % e try: cw = CommsWrapper(sim) except Exception, e: print "CommsWrapper Error: %s" % e try: sw = StrategyWrapper(sim) except Exception, e: print "StrategyWrapper Error: %s" % e