Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
89d57ef
Delete unused penalty_setup_tactic_test.cpp
nycrat Feb 26, 2026
c7261bb
Port move_tactic_test, refactor a bit, write notes for porting
nycrat Feb 26, 2026
47da103
Update TODO.txt
nycrat Feb 26, 2026
1007fd6
pivot kick tk
nycrat Feb 27, 2026
793298d
Fix robots not loading
nycrat Feb 28, 2026
2b26779
Test run_till_end default false time save
nycrat Feb 28, 2026
d207cb2
Add note to proto config widget
nycrat Feb 28, 2026
57f95b5
Get rid of star import
nycrat Feb 28, 2026
a0c8b02
Create simplified simulated test view
nycrat Feb 28, 2026
5c44650
Change signature for sync_setup
nycrat Feb 28, 2026
ec4869f
Use best practices for tactic tests
nycrat Feb 28, 2026
ddd0184
Rename set_worldState to set_world_state
nycrat Feb 28, 2026
9e57499
Best practices example for ball placement play test
nycrat Feb 28, 2026
8bd96ed
Fix hrvo test args
nycrat Mar 1, 2026
7460820
Use best practices for play tests
nycrat Mar 1, 2026
fdcb89d
Formatting
nycrat Mar 1, 2026
6f882e8
Fix order of setup protos, world state sent first
nycrat Mar 1, 2026
ac81455
Add important comments that were accidentally deleted
nycrat Mar 1, 2026
d0b34b9
Fix order of setup in HRVO test
nycrat Mar 1, 2026
bfbb157
Merge branch 'avah/fix_simulated_tests_not_loading_robots' into avah/…
nycrat Mar 1, 2026
f1dbcde
Fix new pivot kick tactic test
nycrat Mar 1, 2026
e9ea126
Move pytest validations to its own directory
nycrat Mar 1, 2026
d655618
Refactor move tactic test
nycrat Mar 1, 2026
0f70d38
Add BUILD to pytest_validations package
nycrat Mar 2, 2026
8ed90e9
Fix updated import path
nycrat Mar 2, 2026
dd7a1df
Add chip, halt, and kick tactic tests
nycrat Mar 2, 2026
5d4a3af
Implement robot at orientation validation
nycrat Mar 2, 2026
6b85f4d
Implement ball kicked (at angle) validation, remove some old validations
nycrat Mar 2, 2026
a9888e6
Implement robot at angular velocity validation
nycrat Mar 2, 2026
3e87e5f
Implement robot received ball (has ball) validation
nycrat Mar 2, 2026
e85512a
Formatting
nycrat Mar 2, 2026
221913c
Port dribble tactic test
nycrat Mar 2, 2026
74b08e4
Add to pivot kick tactic test, disable cause of flakiness
nycrat Mar 2, 2026
e734f87
Minor edits to pivot kick to be more accurate to cpp test
nycrat Mar 4, 2026
5427b43
Port original crease defender tactic tests
nycrat Mar 4, 2026
0858c7a
Merge branch 'master' of github.com:UBC-Thunderbots/Software into ava…
nycrat Mar 5, 2026
afe6520
Fixes with merge
nycrat Mar 5, 2026
d54e03c
Update import
nycrat Mar 5, 2026
ee693e2
Clean up halt tactic test
nycrat Mar 5, 2026
3e0ccfd
Change set_tactics to be cleaner when writing tests
nycrat Mar 5, 2026
6d0ec58
Clean up excessive dribble test
nycrat Mar 5, 2026
e1381cd
Add robot at position validation and clean up move tactic test
nycrat Mar 5, 2026
48b842e
Fix robot at orientation and clean up move tactic test
nycrat Mar 6, 2026
91aedab
Finalize kick tactic test
nycrat Mar 6, 2026
40da72e
Finalize chip tactic test
nycrat Mar 6, 2026
61e5f4e
Fix hrvo test
nycrat Mar 6, 2026
2b4f1a4
Almost finalize dribble tactic test
nycrat Mar 6, 2026
ea227c3
Add receiver tactic tests
nycrat Mar 6, 2026
113337e
Temp fix for defense play test
nycrat Mar 6, 2026
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
33 changes: 33 additions & 0 deletions TODO.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Found using: `rg SimulatedErForceSimPlayTestFixture` and manual sorting

TACTIC TESTS TO PORT

src/software/ai/hl/stp/tactic/pivot_kick/pivot_kick_tactic_test.cpp (DONE 99% ACCURACY)
src/software/ai/hl/stp/tactic/crease_defender/crease_defender_tactic_test.cpp (DONE 99% ACCURACY + ADDITIONAL)
src/software/ai/hl/stp/tactic/halt/halt_tactic_test.cpp (DONE 99% ACCURACY)
src/software/ai/hl/stp/tactic/move/move_tactic_test.cpp (DONE 99%)
src/software/ai/hl/stp/tactic/kick/kick_tactic_test.cpp (DONE 99%)
src/software/ai/hl/stp/tactic/penalty_kick/penalty_kick_tactic_test.cpp (DISABLED)
src/software/ai/hl/stp/tactic/chip/chip_tactic_test.cpp (DONE 99%)
src/software/ai/hl/stp/tactic/dribble/dribble_tactic_test.cpp (DONE 98% need to implement thing)
src/software/ai/hl/stp/tactic/receiver/receiver_tactic_test.cpp (DONE 99%)
src/software/ai/hl/stp/tactic/attacker/attacker_tactic_passing_test.cpp
src/software/ai/hl/stp/tactic/attacker/attacker_tactic_keep_away_test.cpp
src/software/ai/hl/stp/tactic/attacker/attacker_tactic_shoot_goal_test.cpp
src/software/ai/hl/stp/tactic/dribble/dribble_tactic_push_enemy_test.cpp
src/software/ai/hl/stp/tactic/penalty_kick/penalty_kick_tactic_test.cpp

PLAY TESTS TO PORT

src/software/ai/hl/stp/play/kickoff_friendly_play_test.cpp
src/software/ai/hl/stp/play/kickoff_enemy_play_test.cpp
src/software/ai/hl/stp/play/penalty_kick/penalty_kick_play_test.cpp
src/software/ai/hl/stp/play/stop_play_test.cpp
src/software/ai/hl/stp/play/stop_play_test.cpp
src/software/ai/hl/stp/play/example/example_play_test.cpp
src/software/ai/hl/stp/play/free_kick/free_kick_play_test.cpp
src/software/ai/hl/stp/play/shoot_or_chip_play_test.cpp
src/software/ai/hl/stp/play/penalty_kick_enemy/penalty_kick_enemy_play_test.cpp
src/software/ai/hl/stp/play/crease_defense/crease_defense_play_test.cpp
src/software/ai/hl/stp/play/shoot_or_pass/shoot_or_pass_play_test.cpp
src/software/ai/hl/stp/play/hardware_challenge_plays/pass_endurance_play_test.cpp
19 changes: 15 additions & 4 deletions src/proto/message_translation/tbots_protobuf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ def create_world_state(
blue_robot_locations: list[tbots_cpp.Point],
ball_location: tbots_cpp.Point,
ball_velocity: tbots_cpp.Vector,
blue_robot_orientations: list[float] = [],
blue_robot_orientations: list[tbots_cpp.Angle] = [],
blue_robot_velocities: list[tbots_cpp.Vector] = [],
) -> WorldState:
"""Initializes the world from a list of robot locations and ball location/velocity.

Expand All @@ -22,31 +23,41 @@ def create_world_state(
:param ball_location: Location of the ball
:param ball_velocity: Velocity of the ball
:param blue_robot_orientations: A list of blue robots orientations
:param blue_robot_velocities: A list of blue robots velocities
"""
world_state = WorldState()

# TODO (#2558): add param for robot angular velocity since its used for some tests

for robot_id, robot_location in enumerate(yellow_robot_locations):
world_state.yellow_robots[robot_id].CopyFrom(
RobotState(
global_position=Point(
x_meters=robot_location.x(), y_meters=robot_location.y()
),
# Initialize angle of yellow robots the same cause its specified in any tests (yet)
global_orientation=Angle(radians=math.pi),
)
)

for robot_id, robot_location in enumerate(blue_robot_locations):
orientation = 0
try:
orientation = blue_robot_orientations[robot_id]
orientation = blue_robot_orientations[robot_id].toRadians()
except IndexError:
pass
orientation = 0

try:
velocity = blue_robot_velocities[robot_id]
except IndexError:
velocity = tbots_cpp.Vector(0, 0)

world_state.blue_robots[robot_id].CopyFrom(
RobotState(
global_position=Point(
x_meters=robot_location.x(), y_meters=robot_location.y()
),
global_orientation=Angle(radians=orientation),
global_velocity=tbots_cpp.createVectorProto(velocity),
)
)

Expand Down
6 changes: 3 additions & 3 deletions src/software/ai/hl/stp/play/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ py_test(
],
deps = [
"//software:conftest",
"//software/simulated_tests:validation",
"//software/simulated_tests/pytest_validations:all_validations",
requirement("pytest"),
],
)
Expand Down Expand Up @@ -214,7 +214,7 @@ py_test(
],
deps = [
"//software:conftest",
"//software/simulated_tests:validation",
"//software/simulated_tests/pytest_validations:all_validations",
requirement("pytest"),
],
)
Expand Down Expand Up @@ -270,7 +270,7 @@ py_test(
"//proto:software_py_proto",
"//proto:tbots_py_proto",
"//software:conftest",
"//software/simulated_tests:validation",
"//software/simulated_tests/pytest_validations:all_validations",
requirement("pytest"),
],
)
2 changes: 1 addition & 1 deletion src/software/ai/hl/stp/play/ball_placement/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ py_test(
tags = ["exclusive"],
deps = [
"//software:conftest",
"//software/simulated_tests:validation",
"//software/simulated_tests/pytest_validations:all_validations",
requirement("pytest"),
],
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,74 @@
import pytest

import software.python_bindings as tbots_cpp
from software.py_constants import ENEMY_BALL_PLACEMENT_DISTANCE_METERS
from proto.play_pb2 import Play, PlayName
from software.simulated_tests.ball_enters_region import *
from software.simulated_tests.ball_stops_in_region import *
from software.simulated_tests.robot_enters_region import *

from proto.import_all_protos import *
from proto.ssl_gc_common_pb2 import Team
from proto.message_translation.tbots_protobuf import create_world_state
from software.simulated_tests.pytest_validations.ball_enters_region import (
BallAlwaysStaysInRegion,
BallEventuallyEntersRegion,
)
from software.simulated_tests.pytest_validations.robot_enters_region import (
RobotEventuallyExitsRegion,
)
from software.simulated_tests.simulated_test_fixture import (
pytest_main,
)
from proto.message_translation.tbots_protobuf import create_world_state
from proto.ssl_gc_common_pb2 import Team


@pytest.mark.parametrize(
"ball_start_point, ball_placement_point",
[
# test normal ball placement (not edge case)
(tbots_cpp.Point(2, 2), tbots_cpp.Point(0, 1.5)),
# test when ball starting point is outside of the goal line
(tbots_cpp.Point(-4.7, 2.0), tbots_cpp.Point(0, 0.5)),
# test when ball starting point is outside of the side lines
(tbots_cpp.Point(-2.0, 3.2), tbots_cpp.Point(0, -0.5)),
# test when ball starting point is inside of enemy net
(tbots_cpp.Point(4.0, 0), tbots_cpp.Point(2.0, 2.0)),
# test when ball starting point is in friendly net
(tbots_cpp.Point(-4.0, 0), tbots_cpp.Point(-2.0, 2.0)),
],
)
def test_two_ai_ball_placement(
simulated_test_runner, ball_start_point, ball_placement_point
):
run_ball_placement_scenario(
simulated_test_runner, ball_start_point, ball_placement_point
)


@pytest.mark.parametrize(
"ball_start_point, ball_placement_point",
[
# TODO: Remove these ball placement tests until #3561 is resolved
# # 2023 RoboCup ball placement scenarios
# # Scenario 1
# (tbots_cpp.Point(-0.2, -2.8), tbots_cpp.Point(-0.2, 2.8)),
# # Scenario 2
# (tbots_cpp.Point(-3.5, -2.25), tbots_cpp.Point(0, 0)),
# # Scenario 3
# (tbots_cpp.Point(-1.5, -2.25), tbots_cpp.Point(-0.2, -2.8)),
# # Scenario 4
# (tbots_cpp.Point(-4.4, -2.9), tbots_cpp.Point(-0.2, 2.8)),
# # Scenario 5
# (tbots_cpp.Point(-0.5, -0), tbots_cpp.Point(-4.3, 2.8)),
# # Scenario 6
# (tbots_cpp.Point(-1, -3.15), tbots_cpp.Point(-3.5, -2.8)),
# # Scenario 7
# (tbots_cpp.Point(-1, 3.15), tbots_cpp.Point(-3.5, 2.8)),
# # Scenario 8
# (tbots_cpp.Point(-4.45, -0.1), tbots_cpp.Point(-0.5, 2.8)),
],
)
def test_robocup_technical_challenge_placement(
simulated_test_runner, ball_start_point, ball_placement_point
):
run_ball_placement_scenario(
simulated_test_runner, ball_start_point, ball_placement_point, blue_only=True
)


def ball_placement_play_setup(
Expand Down Expand Up @@ -54,12 +112,22 @@ def ball_placement_play_setup(
.negXPosYCorner(),
]

# Create world state
simulated_test_runner.set_world_state(
create_world_state(
yellow_robot_locations=yellow_bots,
blue_robot_locations=blue_bots,
ball_location=ball_start_point,
ball_velocity=tbots_cpp.Vector(0, 0),
),
)

# Game Controller Setup
simulated_test_runner.gamecontroller.send_gc_command(
simulated_test_runner.send_gamecontroller_command(
gc_command=Command.Type.STOP, team=Team.UNKNOWN
)
# Pass in placement point here - not required for all play tests
simulated_test_runner.gamecontroller.send_gc_command(
simulated_test_runner.send_gamecontroller_command(
gc_command=Command.Type.BALL_PLACEMENT,
team=Team.BLUE,
final_ball_placement_point=ball_placement_point,
Expand All @@ -72,76 +140,9 @@ def ball_placement_play_setup(
yellow_play = Play()
yellow_play.name = PlayName.HaltPlay

simulated_test_runner.blue_full_system_proto_unix_io.send_proto(Play, blue_play)
simulated_test_runner.set_play(blue_play, is_friendly=True)
if not blue_only:
simulated_test_runner.yellow_full_system_proto_unix_io.send_proto(
Play, yellow_play
)

# Create world state
simulated_test_runner.simulator_proto_unix_io.send_proto(
WorldState,
create_world_state(
yellow_robot_locations=yellow_bots,
blue_robot_locations=blue_bots,
ball_location=ball_start_point,
ball_velocity=tbots_cpp.Vector(0, 0),
),
)


@pytest.mark.parametrize(
"ball_start_point, ball_placement_point",
[
# test normal ball placement (not edge case)
(tbots_cpp.Point(2, 2), tbots_cpp.Point(0, 1.5)),
# test when ball starting point is outside of the goal line
(tbots_cpp.Point(-4.7, 2.0), tbots_cpp.Point(0, 0.5)),
# test when ball starting point is outside of the side lines
(tbots_cpp.Point(-2.0, 3.2), tbots_cpp.Point(0, -0.5)),
# test when ball starting point is inside of enemy net
(tbots_cpp.Point(4.0, 0), tbots_cpp.Point(2.0, 2.0)),
# test when ball starting point is in friendly net
(tbots_cpp.Point(-4.0, 0), tbots_cpp.Point(-2.0, 2.0)),
],
)
def test_two_ai_ball_placement(
simulated_test_runner, ball_start_point, ball_placement_point
):
run_ball_placement_scenario(
simulated_test_runner, ball_start_point, ball_placement_point
)


@pytest.mark.parametrize(
"ball_start_point, ball_placement_point",
[
# TODO: Remove these ball placement tests until #3561 is resolved
# # 2023 RoboCup ball placement scenarios
# # Scenario 1
# (tbots_cpp.Point(-0.2, -2.8), tbots_cpp.Point(-0.2, 2.8)),
# # Scenario 2
# (tbots_cpp.Point(-3.5, -2.25), tbots_cpp.Point(0, 0)),
# # Scenario 3
# (tbots_cpp.Point(-1.5, -2.25), tbots_cpp.Point(-0.2, -2.8)),
# # Scenario 4
# (tbots_cpp.Point(-4.4, -2.9), tbots_cpp.Point(-0.2, 2.8)),
# # Scenario 5
# (tbots_cpp.Point(-0.5, -0), tbots_cpp.Point(-4.3, 2.8)),
# # Scenario 6
# (tbots_cpp.Point(-1, -3.15), tbots_cpp.Point(-3.5, -2.8)),
# # Scenario 7
# (tbots_cpp.Point(-1, 3.15), tbots_cpp.Point(-3.5, 2.8)),
# # Scenario 8
# (tbots_cpp.Point(-4.45, -0.1), tbots_cpp.Point(-0.5, 2.8)),
],
)
def test_robocup_technical_challenge_placement(
simulated_test_runner, ball_start_point, ball_placement_point
):
run_ball_placement_scenario(
simulated_test_runner, ball_start_point, ball_placement_point, blue_only=True
)
simulated_test_runner.set_play(yellow_play, is_friendly=False)


def run_ball_placement_scenario(
Expand All @@ -150,8 +151,8 @@ def run_ball_placement_scenario(
"""Runs a ball placement test scenario with the specified parameters.

:param simulated_test_runner: The test runner used to simulate robot and ball behavior.
:param ball_start_point: The initial position of the ball (provided by pytest parameterization).
:param ball_placement_point: The target position where the ball should be placed (provided by pytest parameterization).
:param ball_start_point: The initial position of the ball.
:param ball_placement_point: The target position where the ball should be placed.
:param blue_only: If True, only the blue team is active; the yellow team is ignored.
"""
# Placement Eventually Validation
Expand Down
2 changes: 1 addition & 1 deletion src/software/ai/hl/stp/play/crease_defense/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ py_test(
],
deps = [
"//software:conftest",
"//software/simulated_tests:validation",
"//software/simulated_tests/pytest_validations:all_validations",
requirement("pytest"),
],
)
Expand Down
Loading