class VisionTestStrategy(TeamStrategyBase): do_visualize = True use_vision = True latency = 0 visualizer_class = ClickVisualizer THIS_SERVER = ('0.0.0.0', 9002) VISION_SERVER = ('127.0.0.1', 9001) CONTROL_SERVER = ('0.0.0.0', 9003) serializer_class = VsssSerializerReal def set_up(self): super(VisionTestStrategy, self).set_up() self.controller = Controller() def strategy(self, data): # global vitoko_gay # vitoko_gay = not vitoko_gay # if vitoko_gay: # return VsssOutData(moves=[Move()]*3) # print data.teams, data.ball team = data.teams[self.team] ball = data.ball goal = RobotPosition(ball.x, ball.y, ball.angle_to(Position(75, 0))) out_data = VsssOutData(moves=[ self.controller.go_to_from(goal, team[0]), Move(0, 0), Move(0, 0), # self.controller.go_to_from(goal, team[1]), # self.controller.go_to_from(goal, team[2]), ]) print out_data.moves return out_data
class VisionTestStrategy(TeamStrategyBase): do_visualize = True use_vision = True latency = 0 visualizer_class = ClickVisualizer THIS_SERVER = ('0.0.0.0', 9002) VISION_SERVER = ('127.0.0.1', 9001) CONTROL_SERVER = ('0.0.0.0', 9003) serializer_class = VsssSerializerReal def set_up(self): super(VisionTestStrategy, self).set_up() self.controller = Controller() def strategy(self, data): # global vitoko_gay # vitoko_gay = not vitoko_gay # if vitoko_gay: # return VsssOutData(moves=[Move()]*3) # print data.teams, data.ball team = data.teams[self.team] ball = data.ball goal = RobotPosition(ball.x, ball.y, ball.angle_to(Position(75, 0))) out_data = VsssOutData(moves=[ self.controller.go_to_from(goal, team[0]), Move(0,0), Move(0,0), # self.controller.go_to_from(goal, team[1]), # self.controller.go_to_from(goal, team[2]), ]) print out_data.moves return out_data
class GoWithAngleStrategy(TeamStrategyBase): use_control = True do_visualize = True visualizer_class = MyVisualizer use_vision = True latency = 20 THIS_SERVER = ('0.0.0.0', 9010) VISION_SERVER = ('0.0.0.0', 9009) CONTROL_SERVER = ('0.0.0.0', 9009) serializer_class = VsssSerializerSimulator def set_up(self): super(GoWithAngleStrategy, self).set_up() self.controller = Controller() self.file = open("data.txt", "w") def strategy(self, data): global temp_goal global prev_time cur_time = time.time() print "TIME ELAPSED:",time.time() - prev_time prev_time = cur_time goal = RobotPosition(data.ball.x, data.ball.y, data.ball.angle_to(Position(75, 0))) obstacles = data.teams[0] obstacles.extend(data.teams[1]) obstacles.remove(data.teams[self.team][1]) temp_goal = self.controller.get_reference_position(goal, data.teams[self.team][1], obstacles=obstacles) my_move = self.controller.go_to_from_with_angle(goal, data.teams[self.team][1], vel=1, obstacles=obstacles) self.file.write(str(data.teams[self.team][1])+"\n") if data.teams[self.team][1].distance_to(goal)<=9: my_move = Move(0,0) # if data.teams[self.team][1].has_in_front(goal): # my_move = self.controller.go_to_from(Position(75, 0), data.teams[self.team][1], vel=0.5) # my_move = self.controller.go_to_from(goal, data.teams[self.team][1], vel=0.5) return VsssOutData(moves=[ Move(0,0), my_move, Move(0,0) ]) def tear_down(self): super(GoWithAngleStrategy, self).tear_down() self.file.close()
class GoWithAngleStrategy(TeamStrategyBase): use_control = True do_visualize = True visualizer_class = MyVisualizer use_vision = True latency = 20 THIS_SERVER = ('0.0.0.0', 9010) VISION_SERVER = ('0.0.0.0', 9009) CONTROL_SERVER = ('0.0.0.0', 9009) serializer_class = VsssSerializerSimulator def set_up(self): super(GoWithAngleStrategy, self).set_up() self.controller = Controller() self.file = open("data.txt", "w") def strategy(self, data): global temp_goal global prev_time cur_time = time.time() print "TIME ELAPSED:", time.time() - prev_time prev_time = cur_time goal = RobotPosition(data.ball.x, data.ball.y, data.ball.angle_to(Position(75, 0))) obstacles = data.teams[0] obstacles.extend(data.teams[1]) obstacles.remove(data.teams[self.team][1]) temp_goal = self.controller.get_reference_position( goal, data.teams[self.team][1], obstacles=obstacles) my_move = self.controller.go_to_from_with_angle( goal, data.teams[self.team][1], vel=1, obstacles=obstacles) self.file.write(str(data.teams[self.team][1]) + "\n") if data.teams[self.team][1].distance_to(goal) <= 9: my_move = Move(0, 0) # if data.teams[self.team][1].has_in_front(goal): # my_move = self.controller.go_to_from(Position(75, 0), data.teams[self.team][1], vel=0.5) # my_move = self.controller.go_to_from(goal, data.teams[self.team][1], vel=0.5) return VsssOutData(moves=[Move(0, 0), my_move, Move(0, 0)]) def tear_down(self): super(GoWithAngleStrategy, self).tear_down() self.file.close()
class SeguirBalonStrategy(TeamStrategyBase): latency = 150 do_visualize = True THIS_SERVER = ('0.0.0.0', 9002) CONTROL_SERVER = ('0.0.0.0', 9003) serializer_class = VsssSerializerReal def set_up(self): super(SeguirBalonStrategy, self).set_up() self.controller = Controller() def strategy(self, data): team = data.teams[self.team] ball = data.ball goal = Position(50, 50) move = self.controller.go_to_from(goal, team[0]) print move out_data = VsssOutData(moves=[move, Move(0, 0), Move(0, 0)]) return out_data
class BalonAlArcoStrategy(TeamStrategyBase): CONTROL_SERVER = ('0.0.0.0', 9003) serializer_class = VsssSerializerSimulator do_visualize = True latency = 100 print_iteration_time = False visualizer_class = TrajectoryVisualizer def set_up(self): super(BalonAlArcoStrategy, self).set_up() self.controller = Controller() self.traj = TrajectorySCurve(r=10) def strategy(self, data): global trajectory print "TEAM", data.teams team = data.teams[self.team] ball = data.ball if my_side == 0: goal = Position(-80,0) else: goal = Position(80,0) Abg = ball.angle_to(goal) # angulo ball to goal obj = RobotPosition(ball.x, ball.y, Abg) current = team[1] if current.distance_to(ball) <= 8: new_obj = move_by_radius(ball.tonp(), 10, Abg) obj = RobotPosition(new_obj[0], new_obj[1], Abg) move = self.controller.go_with_trajectory(obj, current) trajectory = self.traj.get_trajectory(obj, current, 10) out_data = VsssOutData(moves=[ Move(0,0), move, Move(0,0), ]) return out_data
class EstimateSpeedStrategy(FirstTimeStrategy): do_visualize = True use_vision = True latency = 0 THIS_SERVER = ('0.0.0.0', 9002) CONTROL_SERVER = ('0.0.0.0', 9003) serializer_class = VsssSerializerSimulator def set_up(self): super(EstimateSpeedStrategy, self).set_up() self.controller = Controller() self.one_points = [] self.two_points = [] self.three_points = [] def strategy(self, data): team = data.teams[self.team] for i, (robot, goal) in enumerate(zip(team, self.goals)): if robot.distance_to(goal) < 2: self.goals[i].x = -goal.x def do_on_first_time(self, data): self.goals = [] team = data.teams[self.team] moves = [] for robot in team: if robot.y > 0: goal = RobotPosition(-60, robot.y, 180) else: goal = RobotPosition(60, robot.y, 0) self.goals.append(goal) moves.append(self.controller.go_to_from(goal, robot)) out_data = VsssOutData(moves=moves) return out_data
def set_up(self): """ Function to set robots position up and initialize the communication with vision server """ super(GKStrategy, self).set_up() self.sock.sendto('', self.VISION_SERVER) #Array for Initial Position for each team, index 0 has red robot positions InitialPositions = [ [ RobotPosition(0, 0, 180), RobotPosition(50, 10, 180) ], [ RobotPosition(0, 0, 0), RobotPosition(-50, -10, 0) ] ] #setting robot positions up self.goalkeeper_controller = Controller()
def set_up(self): super(VisionTestStrategy, self).set_up() self.controller = Controller()
def set_up(self): super(EstimateSpeedStrategy, self).set_up() self.controller = Controller() self.one_points = [] self.two_points = [] self.three_points = []
def set_up(self): super(GoWithAngleStrategy, self).set_up() self.controller = Controller() self.file = open("data.txt", "w")
def set_up(self): super(SeguirBalonStrategy, self).set_up() self.controller = Controller()
def set_up(self): super(BalonAlArcoStrategy, self).set_up() self.controller = Controller() self.traj = TrajectorySCurve(r=10)