def _update_field_const(self): self.our_goal = Position(self.our_goal_x, 0) self.our_goal_pose = Pose(self.our_goal, 0) self.their_goal = Position(self.their_goal_x, 0) self.their_goal_pose = Pose(self.their_goal, 0) p1 = self.field_lines["RightPenaltyStretch"].p1 p2 = self.field_lines["RightPenaltyStretch"].p2 p3 = self.field_lines["RightFieldLeftPenaltyStretch"].p1 p4 = self.field_lines["RightFieldLeftPenaltyStretch"].p2 self.our_goal_area = Area.from_4_point(p1, p2, p3, p4) self.their_goal_area = Area.flip_x(self.our_goal_area) self.goal_line = Line(p1=Position(self.our_goal_x, +self.goal_width / 2), p2=Position(self.our_goal_x, -self.goal_width / 2)) self.our_goal_line = Line(p1=Position(self.our_goal_x, +self.goal_width / 2), p2=Position(self.our_goal_x, -self.goal_width / 2)) self.their_goal_line = Line(p1=Position(self.their_goal_x, +self.goal_width / 2), p2=Position(self.their_goal_x, -self.goal_width / 2)) self.behind_our_goal_line = Area.from_limits(self.our_goal_area.top, self.our_goal_area.bottom, self.our_goal_area.right + 50 * self.goal_depth, self.our_goal_area.left) self.behind_their_goal_line = Area.flip_x(self.behind_our_goal_line) self.free_kick_avoid_area = Area.pad(self.their_goal_area, INDIRECT_KICK_OFFSET + KEEPOUT_DISTANCE_FROM_GOAL) self.our_goal_forbidden_area = Area.pad(self.our_goal_area, KEEPOUT_DISTANCE_FROM_GOAL) self.their_goal_forbidden_area = Area.pad(self.their_goal_area, KEEPOUT_DISTANCE_FROM_GOAL) self.center = Position(0, 0)
def __init__(self, game_state: GameState, player: Player, target: Optional[Pose]=None, args: Optional[List[Any]]=None, forbidden_areas: Optional[List[Area]]=None): self.logger = logging.getLogger(self.__class__.__name__) assert isinstance(player, Player), "Le player doit être un Player, non un '{}'".format(player) assert target is None or isinstance(target, Pose), "La target devrait être une Pose" self.game_state = game_state self.player = player self.player_id = player.id if args is None: self.args = [] else: self.args = args self.current_state = self.halt self.next_state = self.halt self.status_flag = Flags.INIT self.target = target if forbidden_areas is None: field = self.game_state.field # Those limits are for ulaval local only areas = field.border_limits areas += [ self.field.behind_our_goal_line, self.field.behind_their_goal_line] #areas = [] self.forbidden_areas = [Area.pad(area, KEEPOUT_DISTANCE_FROM_GOAL) for area in areas] self.forbidden_areas += [self.game_state.field.their_goal_forbidden_area, self.game_state.field.our_goal_forbidden_area] else: self.forbidden_areas = forbidden_areas
def __init__( self, game_state: GameState, player: Player, target: Pose = Pose(), penalty_kick=False, args: List[str] = None, ): forbidden_area = [ Area.pad(game_state.field.their_goal_area, KEEPOUT_DISTANCE_FROM_GOAL) ] super().__init__(game_state, player, target, args, forbidden_areas=forbidden_area) self.current_state = self.defense self.next_state = self.defense self.target = Pose( self.game_state.field.our_goal, np.pi) # Ignore target argument, always go for our goal self.go_kick_tactic = None # Used by clear self.last_intersection = None # For debug self.OFFSET_FROM_GOAL_LINE = Position(ROBOT_RADIUS + 10, 0) self.GOAL_LINE = self.game_state.field.our_goal_line
def _update_field_const(self): self.our_goal = Position(self.our_goal_x, 0) self.our_goal_pose = Pose(self.our_goal, 0) self.their_goal = Position(self.their_goal_x, 0) self.their_goal_pose = Pose(self.their_goal, 0) p1 = self.field_lines["RightPenaltyStretch"].p1 p2 = self.field_lines["RightPenaltyStretch"].p2 p3 = self.field_lines["RightFieldLeftPenaltyStretch"].p1 p4 = self.field_lines["RightFieldLeftPenaltyStretch"].p2 self.our_goal_area = Area.from_4_point(p1, p2, p3, p4) self.their_goal_area = Area.flip_x(self.our_goal_area) self.goal_line = Line(p1=Position(self.our_goal_x, +self.goal_width / 2), p2=Position(self.our_goal_x, -self.goal_width / 2)) self.our_goal_line = Line(p1=Position(self.our_goal_x, +self.goal_width / 2), p2=Position(self.our_goal_x, -self.goal_width / 2)) self.their_goal_line = Line(p1=Position(self.their_goal_x, +self.goal_width / 2), p2=Position(self.their_goal_x, -self.goal_width / 2)) self.behind_our_goal_line = Area.from_limits( self.our_goal_area.top, self.our_goal_area.bottom, self.our_goal_area.right + 50 * self.goal_depth, self.our_goal_area.left) self.behind_their_goal_line = Area.flip_x(self.behind_our_goal_line) self.free_kick_avoid_area = Area.pad( self.their_goal_area, INDIRECT_KICK_OFFSET + KEEPOUT_DISTANCE_FROM_GOAL) self.our_goal_forbidden_area = Area.pad(self.our_goal_area, KEEPOUT_DISTANCE_FROM_GOAL) self.their_goal_forbidden_area = Area.pad(self.their_goal_area, KEEPOUT_DISTANCE_FROM_GOAL) self.center = Position(0, 0)
def __init__(self, game_state: GameState, player: Player, target: Pose=Pose(), penalty_kick=False, args: List[str]=None,): forbidden_area = [Area.pad(game_state.field.their_goal_area, KEEPOUT_DISTANCE_FROM_GOAL)] super().__init__(game_state, player, target, args, forbidden_areas=forbidden_area) self.current_state = self.defense self.next_state = self.defense self.target = Pose(self.game_state.field.our_goal, np.pi) # Ignore target argument, always go for our goal self.go_kick_tactic = None # Used by clear self.last_intersection = None # For debug self.OFFSET_FROM_GOAL_LINE = Position(ROBOT_RADIUS + 10, 0) self.GOAL_LINE = self.game_state.field.our_goal_line
def __init__(self, game_state: GameState, player: Player, target: Optional[Pose] = None, args: Optional[List[Any]] = None, forbidden_areas: Optional[List[Area]] = None): self.logger = logging.getLogger(self.__class__.__name__) assert isinstance( player, Player), "Le player doit être un Player, non un '{}'".format( player) assert target is None or isinstance( target, Pose), "La target devrait être une Pose" self.game_state = game_state self.player = player self.player_id = player.id if args is None: self.args = [] else: self.args = args self.current_state = self.halt self.next_state = self.halt self.status_flag = Flags.INIT self.target = target if forbidden_areas is None: field = self.game_state.field # Those limits are for ulaval local only areas = field.border_limits areas += [ self.field.behind_our_goal_line, self.field.behind_their_goal_line ] #areas = [] self.forbidden_areas = [ Area.pad(area, KEEPOUT_DISTANCE_FROM_GOAL) for area in areas ] self.forbidden_areas += [ self.game_state.field.their_goal_forbidden_area, self.game_state.field.our_goal_forbidden_area ] else: self.forbidden_areas = forbidden_areas