-
Notifications
You must be signed in to change notification settings - Fork 126
Penalty kick play pytest #3475
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Penalty kick play pytest #3475
Changes from all commits
39c2e33
66e345d
d760496
921b5c4
2c86881
149af32
cbd7a74
d16e655
54d91b5
343dc64
4326f72
8a08504
734f1a3
caf3295
58ea4ae
bffa453
fc01743
5a7ebec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,215 @@ | ||
| import sys | ||
|
|
||
| import pytest | ||
|
|
||
| import software.python_bindings as tbots_cpp | ||
|
|
||
|
|
||
| from software.simulated_tests.ball_enters_region import BallEventuallyEntersRegion | ||
| from software.simulated_tests.ball_moves_forward import BallAlwaysMovesForward | ||
| from software.simulated_tests.friendly_has_ball_possession import ( | ||
| FriendlyAlwaysHasBallPossession, | ||
| ) | ||
| from software.simulated_tests.friendly_team_scored import FriendlyTeamEventuallyScored | ||
|
|
||
| from proto.message_translation.tbots_protobuf import create_world_state | ||
| from proto.import_all_protos import * | ||
| from proto.ssl_gc_common_pb2 import Team | ||
| from proto.play_pb2 import Play, PlayName | ||
|
|
||
| from software.simulated_tests.robot_enters_region import ( | ||
| NumberOfRobotsEventuallyEntersRegion, | ||
| ) | ||
|
|
||
|
|
||
| def test_penalty_kick_play_setup(simulated_test_runner): | ||
| ball_initial_pos = tbots_cpp.Point(-1.5, 0) | ||
|
|
||
| def setup(*args): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing docstring, add param docs for |
||
| # Setup Bots | ||
| blue_bots = [ | ||
| tbots_cpp.Point(3, 2.5), | ||
| tbots_cpp.Point(2, 1.5), | ||
| tbots_cpp.Point(-1, 0.5), | ||
| tbots_cpp.Point(1, -0.5), | ||
| tbots_cpp.Point(0, -1.5), | ||
| tbots_cpp.Point(-3, -2.5), | ||
| ] | ||
|
|
||
| yellow_bots = [ | ||
| tbots_cpp.Point(1, 0), | ||
| tbots_cpp.Point(1, 2.5), | ||
| tbots_cpp.Point(1, -2.5), | ||
| tbots_cpp.Field.createSSLDivisionBField().enemyGoalCenter(), | ||
| tbots_cpp.Field.createSSLDivisionBField() | ||
| .enemyDefenseArea() | ||
| .negXNegYCorner(), | ||
| tbots_cpp.Field.createSSLDivisionBField() | ||
| .enemyDefenseArea() | ||
| .negXPosYCorner(), | ||
| ] | ||
|
|
||
| # Force play override here | ||
| blue_play = Play() | ||
| blue_play.name = PlayName.PenaltyKickPlay | ||
|
|
||
| yellow_play = Play() | ||
| yellow_play.name = PlayName.PenaltyKickEnemyPlay | ||
|
|
||
| simulated_test_runner.blue_full_system_proto_unix_io.send_proto(Play, blue_play) | ||
| simulated_test_runner.yellow_full_system_proto_unix_io.send_proto( | ||
| Play, yellow_play | ||
| ) | ||
|
|
||
| # Game Controller Setup | ||
| simulated_test_runner.gamecontroller.send_gc_command( | ||
| gc_command=Command.Type.STOP, team=Team.UNKNOWN | ||
| ) | ||
|
|
||
| simulated_test_runner.gamecontroller.send_gc_command( | ||
| gc_command=Command.Type.NORMAL_START, team=Team.BLUE | ||
| ) | ||
|
|
||
| simulated_test_runner.gamecontroller.send_gc_command( | ||
| gc_command=Command.Type.PENALTY, team=Team.BLUE | ||
| ) | ||
|
|
||
| # 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_initial_pos, | ||
| ball_velocity=tbots_cpp.Vector(0, 0), | ||
| ), | ||
| ) | ||
|
|
||
| field = tbots_cpp.Field.createSSLDivisionBField() | ||
|
|
||
| # Always Validation | ||
| inv_always_validation_sequence_set = [[]] | ||
|
|
||
| ag_always_validation_sequence_set = [[]] | ||
|
|
||
| # Eventually Validation | ||
| inv_eventually_validation_sequence_set = [ | ||
| [ | ||
| NumberOfRobotsEventuallyEntersRegion( | ||
| region=tbots_cpp.Rectangle( | ||
| tbots_cpp.Point(-4.5, -3), tbots_cpp.Point(-2.5, 3) | ||
| ), | ||
| req_robot_cnt=5, | ||
| ), | ||
| NumberOfRobotsEventuallyEntersRegion( | ||
| region=tbots_cpp.Circle(ball_initial_pos, 0.5), req_robot_cnt=1 | ||
| ), | ||
| ] | ||
| ] | ||
| ag_eventually_validation_sequence_set = [[]] | ||
|
|
||
| simulated_test_runner.run_test( | ||
| params=[0], | ||
| setup=setup, | ||
| inv_eventually_validation_sequence_set=inv_eventually_validation_sequence_set, | ||
| inv_always_validation_sequence_set=inv_always_validation_sequence_set, | ||
| ag_eventually_validation_sequence_set=ag_eventually_validation_sequence_set, | ||
| ag_always_validation_sequence_set=ag_always_validation_sequence_set, | ||
| test_timeout_s=15, | ||
| ) | ||
|
|
||
|
|
||
| def test_penalty_kick_play_kick(simulated_test_runner): | ||
| ball_initial_pos = tbots_cpp.Point(-1.5, 0) | ||
|
|
||
| def setup(*args): | ||
| # Setup Bots | ||
| blue_bots = [ | ||
| tbots_cpp.Point(-3, 2.5), | ||
| tbots_cpp.Point(-3, 1.5), | ||
| tbots_cpp.Point(-3, 0.5), | ||
| tbots_cpp.Point(-3, -0.5), | ||
| tbots_cpp.Point(-3, -1.5), | ||
| tbots_cpp.Point(-3, -2.5), | ||
| ] | ||
|
|
||
| yellow_bots = [ | ||
| tbots_cpp.Point(-2.5, 0), | ||
| tbots_cpp.Point(-2.5, 1.5), | ||
| tbots_cpp.Point(-2.5, -1.5), | ||
| tbots_cpp.Point(-2.5, 2.5), | ||
| tbots_cpp.Point(-2.5, -2.5), | ||
| tbots_cpp.Field.createSSLDivisionBField().enemyGoalCenter(), | ||
| ] | ||
|
|
||
| # Force play override here | ||
| blue_play = Play() | ||
| blue_play.name = PlayName.PenaltyKickPlay | ||
|
|
||
| yellow_play = Play() | ||
| yellow_play.name = PlayName.PenaltyKickEnemyPlay | ||
|
|
||
| simulated_test_runner.blue_full_system_proto_unix_io.send_proto(Play, blue_play) | ||
| simulated_test_runner.yellow_full_system_proto_unix_io.send_proto( | ||
| Play, yellow_play | ||
| ) | ||
|
|
||
| # Game Controller Setup | ||
| simulated_test_runner.gamecontroller.send_gc_command( | ||
| gc_command=Command.Type.STOP, team=Team.UNKNOWN | ||
| ) | ||
|
|
||
| simulated_test_runner.gamecontroller.send_gc_command( | ||
| gc_command=Command.Type.NORMAL_START, team=Team.BLUE | ||
| ) | ||
|
|
||
| simulated_test_runner.gamecontroller.send_gc_command( | ||
| gc_command=Command.Type.PENALTY, team=Team.BLUE | ||
| ) | ||
| simulated_test_runner.gamecontroller.send_gc_command( | ||
| gc_command=Command.Type.NORMAL_START, team=Team.BLUE | ||
| ) | ||
|
|
||
| # 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_initial_pos, | ||
| ball_velocity=tbots_cpp.Vector(0, 0), | ||
| ), | ||
| ) | ||
|
|
||
| field = tbots_cpp.Field.createSSLDivisionBField() | ||
|
|
||
| # Always Validation | ||
| inv_always_validation_sequence_set = [[]] | ||
|
|
||
| ag_always_validation_sequence_set = [ | ||
| [FriendlyAlwaysHasBallPossession(), BallAlwaysMovesForward(ball_initial_pos)] | ||
| ] | ||
|
|
||
| # Eventually Validation | ||
| inv_eventually_validation_sequence_set = [ | ||
| [ | ||
| FriendlyTeamEventuallyScored(), | ||
| BallEventuallyEntersRegion(regions=[field.enemyDefenseArea()]), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this validation is kinda redundant considering we have |
||
| ] | ||
| ] | ||
| ag_eventually_validation_sequence_set = [[]] | ||
|
|
||
| simulated_test_runner.run_test( | ||
| params=[0], | ||
| setup=setup, | ||
| inv_eventually_validation_sequence_set=inv_eventually_validation_sequence_set, | ||
| inv_always_validation_sequence_set=inv_always_validation_sequence_set, | ||
| ag_eventually_validation_sequence_set=ag_eventually_validation_sequence_set, | ||
| ag_always_validation_sequence_set=ag_always_validation_sequence_set, | ||
| test_timeout_s=15, | ||
| ) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| # Run the test, -s disables all capturing at -vv increases verbosity | ||
| sys.exit(pytest.main([__file__, "-svv"])) | ||
Uh oh!
There was an error while loading. Please reload this page.