Beispiel #1
0
(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()

while not simulation.done.value:
    pass
    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

try:
    vss = VisionServerStarter(vw, 400)
    vss.start(31430)
except Exception, e:
    print "VSS Error: %s" % e

try:
    csf = CommsServerFactory(cw)
    csf.start(31420)
except Exception, e:
    print "CSF Error: %s" % e


done = False
while not done:
    try:
        pass