Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions utama_core/config/formations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Comment thread
energy-in-joles marked this conversation as resolved.
Args:
bounds: FieldBounds object defining the top-left and bottom-right corners of the field.
Comment thread
energy-in-joles marked this conversation as resolved.
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.
Expand Down
3 changes: 1 addition & 2 deletions utama_core/rsoccer_simulator/src/ssl/envs/standard_ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions utama_core/run/strategy_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down
11 changes: 2 additions & 9 deletions utama_core/strategy/examples/startup_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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()
Expand Down
3 changes: 1 addition & 2 deletions utama_core/tests/strategy_runner/test_grsim_sim_setup.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions utama_core/tests/strategy_runner/test_rsim_formations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
Loading