|
1 | | -from proto.import_all_protos import * |
2 | | -from software.field_tests.field_test_fixture import * |
| 1 | +import math |
3 | 2 |
|
4 | | -from software.gameplay_tests.util import * |
| 3 | +from proto.import_all_protos import * |
| 4 | +from software.gameplay_tests.util import pytest_main |
5 | 5 | from software.logger.logger import create_logger |
6 | | -import math |
7 | 6 |
|
8 | 7 | logger = create_logger(__name__) |
9 | 8 |
|
10 | 9 |
|
11 | | -# TODO 2908: Support running this test in both simulator or field mode |
| 10 | +# TODO(#2908): Support running this test in both simulator or field mode |
12 | 11 | # this test can be run either in simulation or on the field |
13 | 12 | # @pytest.mark.parametrize( |
14 | 13 | # "robot_x_destination, robot_y_destination", |
|
66 | 65 | # test_timeout_s=5, |
67 | 66 | # ) |
68 | 67 |
|
69 | | - |
| 68 | +# TODO(#2908): uncomment this |
70 | 69 | # this test can only be run on the field |
71 | | -def test_basic_rotation(field_test_runner): |
72 | | - test_angles = [0, 45, 90, 180, 270, 0] |
| 70 | +# def test_basic_rotation(field_test_runner): |
| 71 | +# test_angles = [0, 45, 90, 180, 270, 0] |
| 72 | +# |
| 73 | +# world = field_test_runner.world_buffer.get(block=True, timeout=WORLD_BUFFER_TIMEOUT) |
| 74 | +# if len(world.friendly_team.team_robots) == 0: |
| 75 | +# raise Exception("The first world received had no robots in it!") |
| 76 | +# |
| 77 | +# print("Here are the robots:") |
| 78 | +# print( |
| 79 | +# [ |
| 80 | +# robot.current_state.global_position |
| 81 | +# for robot in world.friendly_team.team_robots |
| 82 | +# ] |
| 83 | +# ) |
| 84 | +# |
| 85 | +# id = world.friendly_team.team_robots[0].id |
| 86 | +# print(f"Running test on robot {id}") |
| 87 | +# |
| 88 | +# robot = world.friendly_team.team_robots[0] |
| 89 | +# rob_pos_p = robot.current_state.global_position |
| 90 | +# logger.info("staying in pos {rob_pos_p}") |
| 91 | +# |
| 92 | +# for angle in test_angles: |
| 93 | +# move_tactic = MoveTactic() |
| 94 | +# move_tactic.destination.CopyFrom(rob_pos_p) |
| 95 | +# move_tactic.dribbler_mode = DribblerMode.OFF |
| 96 | +# move_tactic.final_orientation.CopyFrom(Angle(radians=angle)) |
| 97 | +# move_tactic.ball_collision_type = BallCollisionType.AVOID |
| 98 | +# move_tactic.auto_chip_or_kick.CopyFrom( |
| 99 | +# AutoChipOrKick(autokick_speed_m_per_s=0.0) |
| 100 | +# ) |
| 101 | +# move_tactic.max_allowed_speed_mode = MaxAllowedSpeedMode.PHYSICAL_LIMIT |
| 102 | +# move_tactic.obstacle_avoidance_mode = ObstacleAvoidanceMode.SAFE |
| 103 | +# |
| 104 | +# # Setup Tactic |
| 105 | +# field_test_runner.set_tactics( |
| 106 | +# blue_tactics={id: move_tactic}, yellow_tactics=None |
| 107 | +# ) |
| 108 | +# field_test_runner.run_test( |
| 109 | +# always_validation_sequence_set=[[]], |
| 110 | +# eventually_validation_sequence_set=[[]], |
| 111 | +# test_timeout_s=5, |
| 112 | +# ) |
| 113 | +# # Send a halt tactic after the test finishes |
| 114 | +# field_test_runner.set_tactics( |
| 115 | +# blue_tactics={id: HaltTactic()}, yellow_tactics=None |
| 116 | +# ) |
| 117 | +# |
| 118 | +# # validate by eye |
| 119 | +# logger.info(f"robot set to {angle} orientation") |
| 120 | +# |
| 121 | +# time.sleep(2) |
73 | 122 |
|
74 | | - world = field_test_runner.world_buffer.get(block=True, timeout=WORLD_BUFFER_TIMEOUT) |
75 | | - if len(world.friendly_team.team_robots) == 0: |
76 | | - raise Exception("The first world received had no robots in it!") |
77 | 123 |
|
78 | | - print("Here are the robots:") |
79 | | - print( |
80 | | - [ |
81 | | - robot.current_state.global_position |
82 | | - for robot in world.friendly_team.team_robots |
83 | | - ] |
| 124 | +def test_one_robots_square(gameplay_test_runner): |
| 125 | + world = gameplay_test_runner.world_buffer.get( |
| 126 | + block=True, timeout=WORLD_BUFFER_TIMEOUT |
84 | 127 | ) |
85 | | - |
86 | | - id = world.friendly_team.team_robots[0].id |
87 | | - print(f"Running test on robot {id}") |
88 | | - |
89 | | - robot = world.friendly_team.team_robots[0] |
90 | | - rob_pos_p = robot.current_state.global_position |
91 | | - logger.info("staying in pos {rob_pos_p}") |
92 | | - |
93 | | - for angle in test_angles: |
94 | | - move_tactic = MoveTactic() |
95 | | - move_tactic.destination.CopyFrom(rob_pos_p) |
96 | | - move_tactic.dribbler_mode = DribblerMode.OFF |
97 | | - move_tactic.final_orientation.CopyFrom(Angle(radians=angle)) |
98 | | - move_tactic.ball_collision_type = BallCollisionType.AVOID |
99 | | - move_tactic.auto_chip_or_kick.CopyFrom( |
100 | | - AutoChipOrKick(autokick_speed_m_per_s=0.0) |
101 | | - ) |
102 | | - move_tactic.max_allowed_speed_mode = MaxAllowedSpeedMode.PHYSICAL_LIMIT |
103 | | - move_tactic.obstacle_avoidance_mode = ObstacleAvoidanceMode.SAFE |
104 | | - |
105 | | - # Setup Tactic |
106 | | - field_test_runner.set_tactics( |
107 | | - blue_tactics={id: move_tactic}, yellow_tactics=None |
108 | | - ) |
109 | | - field_test_runner.run_test( |
110 | | - always_validation_sequence_set=[[]], |
111 | | - eventually_validation_sequence_set=[[]], |
112 | | - test_timeout_s=5, |
113 | | - ) |
114 | | - # Send a halt tactic after the test finishes |
115 | | - field_test_runner.set_tactics( |
116 | | - blue_tactics={id: HaltTactic()}, yellow_tactics=None |
117 | | - ) |
118 | | - |
119 | | - # validate by eye |
120 | | - logger.info(f"robot set to {angle} orientation") |
121 | | - |
122 | | - time.sleep(2) |
123 | | - |
124 | | - |
125 | | -def test_one_robots_square(field_test_runner): |
126 | | - world = field_test_runner.world_buffer.get(block=True, timeout=WORLD_BUFFER_TIMEOUT) |
127 | 128 | if len(world.friendly_team.team_robots) == 0: |
128 | 129 | raise Exception("The first world received had no robots in it!") |
129 | 130 |
|
@@ -184,20 +185,22 @@ def test_one_robots_square(field_test_runner): |
184 | 185 | for tactic in tactics: |
185 | 186 | print(f"Going to {tactic.destination}") |
186 | 187 |
|
187 | | - field_test_runner.set_tactics( |
| 188 | + gameplay_test_runner.set_tactics( |
188 | 189 | blue_tactics={ |
189 | 190 | id: tactic, |
190 | 191 | }, |
191 | 192 | yellow_tactics=None, |
192 | 193 | ) |
193 | | - field_test_runner.run_test( |
| 194 | + gameplay_test_runner.run_test( |
194 | 195 | always_validation_sequence_set=[[]], |
195 | 196 | eventually_validation_sequence_set=[[]], |
196 | 197 | test_timeout_s=4, |
197 | 198 | ) |
198 | 199 |
|
199 | 200 | # Send a halt tactic after the test finishes |
200 | | - field_test_runner.set_tactics(blue_tactics={id: HaltTactic()}, yellow_tactics=None) |
| 201 | + gameplay_test_runner.set_tactics( |
| 202 | + blue_tactics={id: HaltTactic()}, yellow_tactics=None |
| 203 | + ) |
201 | 204 |
|
202 | 205 |
|
203 | 206 | if __name__ == "__main__": |
|
0 commit comments