-
Notifications
You must be signed in to change notification settings - Fork 124
OffensePlayTest checking that there is Never Excessive Dribbling #3536
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
Open
adrianchan787
wants to merge
45
commits into
UBC-Thunderbots:master
Choose a base branch
from
adrianchan787:adrian/offense_play_test_dribble
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
ec7010a
Added NeverExcessivelyDribbles functionality into OffensePlayTest
adrianchan787 b690a45
intermediate commit
adrianchan787 c339388
intermediate change
adrianchan787 a4f6bc0
Switched to world proto subscription measurement
adrianchan787 544bc55
Added excessive dribbling functionality and testing
adrianchan787 d928b5d
Reverted verbosity change which was for print testing previously
adrianchan787 a3929cf
Merge branch 'master' into adrian/offense_play_test_dribble
adrianchan787 32cc42d
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] 5b0b98c
Added error margin of 0.05 to max dribbling distance
adrianchan787 2fb03f8
Merge branch 'adrian/offense_play_test_dribble' of https://github.com…
adrianchan787 dff8853
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] 8336df9
Made testing file one function
adrianchan787 8d1354f
Increased max dribble margin to 0.06 to reduce flakiness
adrianchan787 75141c3
Fixed import statements for test file
adrianchan787 2d235e3
Changed get validation to reflect correct start point
adrianchan787 ed1102e
Merge conflict fix
adrianchan787 e3afcc5
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] 7edc073
Added constants to the excessive dribbling
adrianchan787 87eb7b9
Removed allow excessive dribbling for the tests
adrianchan787 20f5cfd
Merged master
adrianchan787 e9d2ff6
Fixed merge conflict
adrianchan787 0e8e809
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] fd5ceec
Merge branch 'master' into adrian/offense_play_test_dribble
adrianchan787 da98427
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] 0916bcb
Added back import
adrianchan787 82532bd
Added back import
adrianchan787 7e46bdf
Merge conflicts fixed
adrianchan787 6d9a363
Added overrides
adrianchan787 9812bc1
pulled from master
adrianchan787 871d210
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] 9022e22
test
adrianchan787 8a2bf29
fixed syntax
adrianchan787 22ec418
Merge conflicts fixed
adrianchan787 57e14e9
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] 1d98837
i think it's finally good now?
adrianchan787 14ef1b0
test push to see if it fixes the 59 changed files...
adrianchan787 5e15f1a
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] c0632cd
Revert "Added overrides"
adrianchan787 d36bd78
revert
adrianchan787 3edb21c
revert
adrianchan787 6cef848
revert merge
adrianchan787 41344a3
revert
adrianchan787 417a094
merge
adrianchan787 6e3cb23
Revert
adrianchan787 212b4db
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
134 changes: 134 additions & 0 deletions
134
src/software/ai/hl/stp/tactic/dribble/excessive_dribble_test.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,134 @@ | ||
| import pytest | ||
|
|
||
| import software.python_bindings as tbots_cpp | ||
| from software.simulated_tests.excessive_dribbling import ( | ||
| NeverExcessivelyDribbles, | ||
| EventuallyStartsExcessivelyDribbling, | ||
| ) | ||
| from proto.message_translation.tbots_protobuf import ( | ||
| WorldState, | ||
| AssignedTacticPlayControlParams, | ||
| DribbleTactic, | ||
| ) | ||
| from software.simulated_tests.simulated_test_fixture import ( | ||
| pytest_main, | ||
| ) | ||
| from proto.message_translation.tbots_protobuf import create_world_state | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "initial_location,dribble_destination,final_dribble_orientation, should_excessively_dribble", | ||
| [ | ||
| # Tests Should not excessively dribble | ||
| # Dribble Destination for the ball < 1.0 from its starting position | ||
| (tbots_cpp.Point(0.5, 0), tbots_cpp.Point(1.02, 0), tbots_cpp.Angle(), False), | ||
| # Dribble Testing diagonally | ||
| ( | ||
| tbots_cpp.Point(0.25, 0.25), | ||
| tbots_cpp.Point(0.80, 0.50), | ||
| tbots_cpp.Angle.fromRadians(50), | ||
| False, | ||
| ), | ||
| # Boundary Testing, because of the autoref implementation (initial of position Bot to final of Ball), | ||
| # a conservative max dribble distance (0.95 m) is used | ||
| # Test vertical dribbling | ||
| (tbots_cpp.Point(0.01, 0), tbots_cpp.Point(0.96, 0), tbots_cpp.Angle(), False), | ||
| # Test horizontal dribbling | ||
| (tbots_cpp.Point(1, 1.5), tbots_cpp.Point(1.95, 1.5), tbots_cpp.Angle(), False), | ||
| # Test bot and ball in same position | ||
| (tbots_cpp.Point(0, 1), tbots_cpp.Point(0.95, 1), tbots_cpp.Angle(), False), | ||
| # Tests Should excessively dribble | ||
| # Dribble Destination for the ball > 1.0 from its starting position | ||
| (tbots_cpp.Point(0, 2), tbots_cpp.Point(0, 0.5), tbots_cpp.Angle(), True), | ||
| # Dribble Testing diagonally | ||
| ( | ||
| tbots_cpp.Point(0.1, 1.1), | ||
| tbots_cpp.Point(1.1, 0.1), | ||
| tbots_cpp.Angle.fromRadians(50), | ||
| True, | ||
| ), | ||
| # Boundary Testing, due to the conservative implementation a dribble distance of 1 m should fail | ||
| # Test Vertical Dribbling | ||
| (tbots_cpp.Point(0, 1), tbots_cpp.Point(0, 2), tbots_cpp.Angle(), True), | ||
| # Test Horizontal Dribbling | ||
| (tbots_cpp.Point(1, 2), tbots_cpp.Point(0, 2), tbots_cpp.Angle(), True), | ||
| # Test Diagonal Dribbling | ||
| (tbots_cpp.Point(0, 1), tbots_cpp.Point(0.6, 1.8), tbots_cpp.Angle(), True), | ||
| # Test robot and ball at same position (affects dribbling orientation and therefore perceived dribble distance) | ||
| (tbots_cpp.Point(0, 0), tbots_cpp.Point(0, 1), tbots_cpp.Angle(), True), | ||
| ( | ||
| tbots_cpp.Point(0.0, 0.01), | ||
| tbots_cpp.Point(0.81, 0.61), | ||
| tbots_cpp.Angle(), | ||
| True, | ||
| ), | ||
| ( | ||
| tbots_cpp.Point(0.01, 0.00), | ||
| tbots_cpp.Point(0.81, 0.61), | ||
| tbots_cpp.Angle(), | ||
| True, | ||
| ), | ||
| ], | ||
| ) | ||
| def test_excessive_dribbling( | ||
| initial_location, | ||
| dribble_destination, | ||
| final_dribble_orientation, | ||
| should_excessively_dribble, | ||
| simulated_test_runner, | ||
| ): | ||
| if should_excessively_dribble: | ||
| blue_robot_locations = [tbots_cpp.Point(0, 0.0)] | ||
|
|
||
| # Always and Eventually validation sets for excessive dribbling | ||
| always_validation_sequence_set = [[]] | ||
| eventually_validation_sequence_set = [[EventuallyStartsExcessivelyDribbling()]] | ||
| else: | ||
| blue_robot_locations = [tbots_cpp.Point(0, 1)] | ||
|
|
||
| # Always and Eventually validation sets for not excessive dribbling | ||
| always_validation_sequence_set = [[NeverExcessivelyDribbles()]] | ||
| eventually_validation_sequence_set = [[]] | ||
|
|
||
| simulated_test_runner.simulator_proto_unix_io.send_proto( | ||
| WorldState, | ||
| create_world_state( | ||
| [], | ||
| blue_robot_locations=blue_robot_locations, | ||
| ball_location=initial_location, | ||
| ball_velocity=tbots_cpp.Vector(0, 0), | ||
| ), | ||
| ) | ||
|
|
||
| # Setup Tactic | ||
| params = AssignedTacticPlayControlParams() | ||
| params.assigned_tactics[0].dribble.CopyFrom( | ||
| DribbleTactic( | ||
| dribble_destination=tbots_cpp.createPointProto(dribble_destination), | ||
| final_dribble_orientation=tbots_cpp.createAngleProto( | ||
| final_dribble_orientation | ||
| ), | ||
| allow_excessive_dribbling=True, | ||
| ) | ||
| ) | ||
|
|
||
| simulated_test_runner.blue_full_system_proto_unix_io.send_proto( | ||
| AssignedTacticPlayControlParams, params | ||
| ) | ||
|
|
||
| # Setup no tactics on the enemy side | ||
| params = AssignedTacticPlayControlParams() | ||
| simulated_test_runner.yellow_full_system_proto_unix_io.send_proto( | ||
| AssignedTacticPlayControlParams, params | ||
| ) | ||
|
|
||
| simulated_test_runner.run_test( | ||
| inv_eventually_validation_sequence_set=eventually_validation_sequence_set, | ||
| inv_always_validation_sequence_set=always_validation_sequence_set, | ||
| ag_eventually_validation_sequence_set=eventually_validation_sequence_set, | ||
| ag_always_validation_sequence_set=always_validation_sequence_set, | ||
| ) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| pytest_main(__file__) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.