1414
1515
1616def ball_placement_play_setup (
17- ball_start_point , ball_placement_point , simulated_test_runner
17+ ball_start_point , ball_placement_point , simulated_test_runner , blue_only
1818):
19- # Setup Bots
19+ """Set up ball placement test by initializing bot positions, ball placement targets, and test settings
20+
21+ :param ball_start_point: Initial point of the ball
22+ :param ball_placement_point: Target point of the ball
23+ :param simulated_test_runner: Simulated test runner
24+ :param blue_only: If True, only the blue team is active; the yellow team is ignored.
25+ """
26+ # Setup blue robots
2027 blue_bots = [
2128 tbots_cpp .Point (- 2.75 , 1.5 ),
2229 tbots_cpp .Point (- 0.0 , 0.0 ),
@@ -29,14 +36,23 @@ def ball_placement_play_setup(
2936 .friendlyDefenseArea ()
3037 .negXPosYCorner (),
3138 ]
32- yellow_bots = [
33- tbots_cpp .Point (1 , 0 ),
34- tbots_cpp .Point (1 , 2.5 ),
35- tbots_cpp .Point (1 , - 2.5 ),
36- tbots_cpp .Field .createSSLDivisionBField ().enemyGoalCenter (),
37- tbots_cpp .Field .createSSLDivisionBField ().enemyDefenseArea ().negXNegYCorner (),
38- tbots_cpp .Field .createSSLDivisionBField ().enemyDefenseArea ().negXPosYCorner (),
39- ]
39+
40+ yellow_bots = []
41+
42+ # Optionally skip yellow robots entirely
43+ if not blue_only :
44+ yellow_bots = [
45+ tbots_cpp .Point (1 , 0 ),
46+ tbots_cpp .Point (1 , 2.5 ),
47+ tbots_cpp .Point (1 , - 2.5 ),
48+ tbots_cpp .Field .createSSLDivisionBField ().enemyGoalCenter (),
49+ tbots_cpp .Field .createSSLDivisionBField ()
50+ .enemyDefenseArea ()
51+ .negXNegYCorner (),
52+ tbots_cpp .Field .createSSLDivisionBField ()
53+ .enemyDefenseArea ()
54+ .negXPosYCorner (),
55+ ]
4056
4157 # Game Controller Setup
4258 simulated_test_runner .gamecontroller .send_gc_command (
@@ -53,12 +69,14 @@ def ball_placement_play_setup(
5369 blue_play = Play ()
5470 blue_play .name = PlayName .BallPlacementPlay
5571
56- # TODO (#3019): Re-enable enemy ai after enemy ball placement is fixed
5772 yellow_play = Play ()
5873 yellow_play .name = PlayName .HaltPlay
5974
6075 simulated_test_runner .blue_full_system_proto_unix_io .send_proto (Play , blue_play )
61- simulated_test_runner .yellow_full_system_proto_unix_io .send_proto (Play , yellow_play )
76+ if not blue_only :
77+ simulated_test_runner .yellow_full_system_proto_unix_io .send_proto (
78+ Play , yellow_play
79+ )
6280
6381 # Create world state
6482 simulated_test_runner .simulator_proto_unix_io .send_proto (
@@ -72,8 +90,6 @@ def ball_placement_play_setup(
7290 )
7391
7492
75- # TODO (#2599): Remove Duration parameter from test
76- # TODO (#2690): Robot gets stuck in corner of defense area
7793@pytest .mark .parametrize (
7894 "ball_start_point, ball_placement_point" ,
7995 [
@@ -92,6 +108,51 @@ def ball_placement_play_setup(
92108def test_two_ai_ball_placement (
93109 simulated_test_runner , ball_start_point , ball_placement_point
94110):
111+ run_ball_placement_scenario (
112+ simulated_test_runner , ball_start_point , ball_placement_point
113+ )
114+
115+
116+ @pytest .mark .parametrize (
117+ "ball_start_point, ball_placement_point" ,
118+ [
119+ # 2023 RoboCup ball placement scenarios
120+ # Scenario 1
121+ (tbots_cpp .Point (- 0.2 , - 2.8 ), tbots_cpp .Point (- 0.2 , 2.8 )),
122+ # Scenario 2
123+ (tbots_cpp .Point (- 3.5 , - 2.25 ), tbots_cpp .Point (0 , 0 )),
124+ # Scenario 3
125+ (tbots_cpp .Point (- 1.5 , - 2.25 ), tbots_cpp .Point (- 0.2 , - 2.8 )),
126+ # Scenario 4
127+ (tbots_cpp .Point (- 4.4 , - 2.9 ), tbots_cpp .Point (- 0.2 , 2.8 )),
128+ # Scenario 5
129+ (tbots_cpp .Point (- 0.5 , - 0 ), tbots_cpp .Point (- 4.3 , 2.8 )),
130+ # Scenario 6
131+ (tbots_cpp .Point (- 1 , - 3.15 ), tbots_cpp .Point (- 3.5 , - 2.8 )),
132+ # Scenario 7
133+ (tbots_cpp .Point (- 1 , 3.15 ), tbots_cpp .Point (- 3.5 , 2.8 )),
134+ # Scenario 8
135+ (tbots_cpp .Point (- 4.45 , - 0.1 ), tbots_cpp .Point (- 0.5 , 2.8 )),
136+ ],
137+ )
138+ def test_robocup_technical_challenge_placement (
139+ simulated_test_runner , ball_start_point , ball_placement_point
140+ ):
141+ run_ball_placement_scenario (
142+ simulated_test_runner , ball_start_point , ball_placement_point , blue_only = True
143+ )
144+
145+
146+ def run_ball_placement_scenario (
147+ simulated_test_runner , ball_start_point , ball_placement_point , blue_only = False
148+ ):
149+ """Runs a ball placement test scenario with the specified parameters.
150+
151+ :param simulated_test_runner: The test runner used to simulate robot and ball behavior.
152+ :param ball_start_point: The initial position of the ball (provided by pytest parameterization).
153+ :param ball_placement_point: The target position where the ball should be placed (provided by pytest parameterization).
154+ :param blue_only: If True, only the blue team is active; the yellow team is ignored.
155+ """
95156 # Placement Eventually Validation
96157 placement_eventually_validation_sequence_set = [
97158 [
@@ -107,6 +168,7 @@ def test_two_ai_ball_placement(
107168 test_setup_arg ["ball_start_point" ],
108169 test_setup_arg ["ball_placement_point" ],
109170 simulated_test_runner ,
171+ blue_only ,
110172 ),
111173 params = [
112174 {
@@ -151,7 +213,7 @@ def test_two_ai_ball_placement(
151213 inv_eventually_validation_sequence_set = drop_ball_eventually_validation_sequence_set ,
152214 ag_always_validation_sequence_set = drop_ball_always_validation_sequence_set ,
153215 ag_eventually_validation_sequence_set = drop_ball_eventually_validation_sequence_set ,
154- test_timeout_s = [15 ],
216+ test_timeout_s = [30 ],
155217 )
156218
157219
0 commit comments