diff --git a/utama_core/config/formations.py b/utama_core/config/formations.py index 5f2873ee..4708dfc4 100644 --- a/utama_core/config/formations.py +++ b/utama_core/config/formations.py @@ -4,7 +4,7 @@ import numpy as np -from utama_core.config.field_params import FieldBounds, FieldDimensions +from utama_core.config.field_params import FieldBounds from utama_core.config.physical_constants import MAX_ROBOTS, ROBOT_RADIUS from utama_core.global_utils.math_utils import normalise_heading @@ -136,19 +136,19 @@ def _validate_team_separation(left, right): def get_formations( bounds: FieldBounds, - n_right: int, - n_left: int, - formation_type: FormationType, + n_right: int = MAX_ROBOTS, + n_left: int = MAX_ROBOTS, + formation_type: FormationType = FormationType.START_ONE, ) -> tuple[list[FormationEntry], list[FormationEntry]]: """ - Returns the starting formations for both teams based on the provided field dimensions. + Returns the starting formations for both teams based on the provided FieldBounds. The formations are defined as lists of FormationEntry objects, which contain the x and y coordinates Args: bounds: FieldBounds object defining the top-left and bottom-right corners of the field. - n_right: Number of robots on the right team. - n_left: Number of robots on the left team. - formation_type: The type of formation to generate (e.g., START_ONE). + n_right: Number of robots on the right team. Default is MAX_ROBOTS. + n_left: Number of robots on the left team. Default is MAX_ROBOTS. + formation_type: The type of formation to generate (e.g., START_ONE). Default is FormationType.START_ONE. Returns: tuple[list[FormationEntry], list[FormationEntry]]: A tuple containing two lists of FormationEntry objects. diff --git a/utama_core/rsoccer_simulator/src/ssl/envs/standard_ssl.py b/utama_core/rsoccer_simulator/src/ssl/envs/standard_ssl.py index 26d1cd6b..df26c4d8 100644 --- a/utama_core/rsoccer_simulator/src/ssl/envs/standard_ssl.py +++ b/utama_core/rsoccer_simulator/src/ssl/envs/standard_ssl.py @@ -5,7 +5,7 @@ from numpy.random import normal from utama_core.config.field_params import STANDARD_FIELD_DIMS, FieldDimensions -from utama_core.config.formations import FormationEntry, FormationType, get_formations +from utama_core.config.formations import FormationEntry, get_formations from utama_core.config.robot_params import RSIM_PARAMS from utama_core.config.settings import ( MAX_BALL_SPEED, @@ -121,7 +121,6 @@ def __init__( STANDARD_FIELD_DIMS.full_field_bounds, n_right=n_robots_yellow, n_left=n_robots_blue, - formation_type=FormationType.START_ONE, ) # Ball start position is expressed in normal field coordinates used by diff --git a/utama_core/run/strategy_runner.py b/utama_core/run/strategy_runner.py index 450a8d56..36010083 100644 --- a/utama_core/run/strategy_runner.py +++ b/utama_core/run/strategy_runner.py @@ -13,7 +13,7 @@ from utama_core.config.enums import Mode, mode_str_to_enum from utama_core.config.field_params import STANDARD_FIELD_DIMS, FieldDimensions -from utama_core.config.formations import FormationType, get_formations +from utama_core.config.formations import get_formations from utama_core.config.physical_constants import MAX_ROBOTS from utama_core.config.settings import ( FPS_PRINT_INTERVAL, @@ -351,7 +351,6 @@ def _load_sim( bounds=self.field_bounds, n_right=self.exp_friendly if self.my_team_is_right else self.exp_enemy, n_left=self.exp_enemy if self.my_team_is_right else self.exp_friendly, - formation_type=FormationType.START_ONE, ) yellow_start, blue_start = map_left_right_to_colors( diff --git a/utama_core/strategy/examples/startup_strategy.py b/utama_core/strategy/examples/startup_strategy.py index ffcb9607..e83e34ff 100644 --- a/utama_core/strategy/examples/startup_strategy.py +++ b/utama_core/strategy/examples/startup_strategy.py @@ -2,10 +2,8 @@ from py_trees.composites import Sequence from utama_core.config.field_params import STANDARD_FIELD_DIMS -from utama_core.config.formations import FormationType, get_formations -from utama_core.config.physical_constants import MAX_ROBOTS +from utama_core.config.formations import get_formations from utama_core.entities.data.vector import Vector2D -from utama_core.global_utils.math_utils import compute_bounding_zone_from_points from utama_core.skills.src.go_to_point import go_to_point from utama_core.strategy.common import AbstractBehaviour, AbstractStrategy @@ -14,12 +12,7 @@ def generate_starting_positions(is_right_team: bool): """ Generate starting and target formations based on team side. """ - right_formation, left_formation = get_formations( - STANDARD_FIELD_DIMS.full_field_bounds, - MAX_ROBOTS, - MAX_ROBOTS, - formation_type=FormationType.START_ONE, - ) + right_formation, left_formation = get_formations(STANDARD_FIELD_DIMS.full_field_bounds) start_formation = right_formation if is_right_team else left_formation target_formation = start_formation.copy() target_formation.reverse() diff --git a/utama_core/tests/strategy_runner/test_grsim_sim_setup.py b/utama_core/tests/strategy_runner/test_grsim_sim_setup.py index 040d4ac1..509b6783 100644 --- a/utama_core/tests/strategy_runner/test_grsim_sim_setup.py +++ b/utama_core/tests/strategy_runner/test_grsim_sim_setup.py @@ -1,6 +1,6 @@ from unittest.mock import patch -from utama_core.config.formations import FormationType, get_formations +from utama_core.config.formations import get_formations from utama_core.entities.game.field import FieldBounds from utama_core.global_utils.mapping_utils import ( map_friendly_enemy_to_colors, @@ -87,7 +87,6 @@ def test_grsim_spawn_positions_and_ball_use_field_bounds_center(): bounds=bounds, n_right=exp_enemy, n_left=exp_friendly, - formation_type=FormationType.START_ONE, ) expected_yellow, expected_blue = map_left_right_to_colors( my_team_is_yellow, diff --git a/utama_core/tests/strategy_runner/test_rsim_formations.py b/utama_core/tests/strategy_runner/test_rsim_formations.py index 0f90151d..ff116537 100644 --- a/utama_core/tests/strategy_runner/test_rsim_formations.py +++ b/utama_core/tests/strategy_runner/test_rsim_formations.py @@ -4,7 +4,7 @@ import pytest from utama_core.config.field_params import GREAT_EXHIBITION_FIELD_DIMS -from utama_core.config.formations import FormationType, get_formations +from utama_core.config.formations import get_formations from utama_core.entities.game.field import FieldBounds from utama_core.global_utils.mapping_utils import map_left_right_to_colors from utama_core.run.strategy_runner import StrategyRunner @@ -85,7 +85,6 @@ def test_rsim_formation_allocation_and_spawn_positions( bounds=runner.field_bounds, n_right=n_friendly if team_on_right else n_enemy, n_left=n_enemy if team_on_right else n_friendly, - formation_type=FormationType.START_ONE, ) expected_yellow, expected_blue = map_left_right_to_colors( team_is_yellow,