示例#1
0
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
示例#2
0
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 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 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
示例#5
0
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