-
Notifications
You must be signed in to change notification settings - Fork 122
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
base: master
Are you sure you want to change the base?
OffensePlayTest checking that there is Never Excessive Dribbling #3536
Conversation
|
(oops really sorry not sure if i was supposed to resolve the merge conflict) |
…/adrianchan787/Software into adrian/offense_play_test_dribble
nycrat
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some comments, just some refactoring changes recommended but the new implementation of excessive_dribbing validation seems good and the test are thorough
| def test_excessive_dribbling( | ||
| initial_location, | ||
| dribble_destination, | ||
| final_dribble_orientation, | ||
| allow_excessive_dribbling, | ||
| simulated_test_runner, | ||
| ): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps instead of having a separate function for testing excessive dribbling, you could pass in a parameter such as "should_excessively_dribble" which would control if the test expects excessive dribbling or not.
This would reduce the repeated code between the two test functions
| create_validation_geometry, | ||
| create_validation_types, | ||
| ) | ||
| from typing import override |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The @override decorators should be kept, which I think was removed during your merge conflict. Just add these back.
| initial_location, | ||
| dribble_destination, | ||
| final_dribble_orientation, | ||
| allow_excessive_dribbling, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
allow_excessive_dribbling might not be a necessary parameter, since all the tests use True. Is there a scenario where allow_excessive_dribbling should be set to False?
| import software.python_bindings as tbots_cpp | ||
| from proto.play_pb2 import Play, PlayName | ||
|
|
||
| from software.simulated_tests.excessive_dribbling import NeverExcessivelyDribbles |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small nit, I would just use the wildcard import * for consistency with the rest of the validation imports.
But actually there are instances of importing specific names in python in our codebase. This might be another refactoring issue to make our python code more consistent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would leave it as is, using the module imports. It is a better practice to only import what you need so as not to pollute the namespace. Additionally, just as a fun fact, try never to import a raw file as it can lead to some unpredictable behaviour during the import process: https://stackoverflow.com/questions/5748946/pythonic-way-to-resolve-circular-import-statements
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea I also agree with just importing the required functions, should this be a different issue to get rid of all wildcard imports from our python code ?
| import software.python_bindings as tbots_cpp | ||
| from proto.play_pb2 import Play, PlayName | ||
|
|
||
| from software.simulated_tests.excessive_dribbling import NeverExcessivelyDribbles |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would leave it as is, using the module imports. It is a better practice to only import what you need so as not to pollute the namespace. Additionally, just as a fun fact, try never to import a raw file as it can lead to some unpredictable behaviour during the import process: https://stackoverflow.com/questions/5748946/pythonic-way-to-resolve-circular-import-statements
| from software.simulated_tests.robot_enters_region import * | ||
| from software.simulated_tests.ball_enters_region import * | ||
| from software.simulated_tests.ball_moves_in_direction import * | ||
| from software.simulated_tests.friendly_has_ball_possession import * | ||
| from software.simulated_tests.ball_speed_threshold import * | ||
| from software.simulated_tests.robot_speed_threshold import * | ||
| from software.simulated_tests.excessive_dribbling import * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment above regarding module imports. It makes it easier for reviewers to catch unused imports if exact macro names are stated.
| max_dribble_length: float = 1.00, | ||
| max_dribble_error_margin: float = 0.05, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: these are magic numbers, is there some way we can make these constants somewhere? Better yet, they should co-align with whatever thresholds we might already have in our logic.
| if world.HasField("dribble_displacement"): | ||
| dribble_disp = world.dribble_displacement | ||
| dist = tbots_cpp.createSegment(dribble_disp).length() | ||
| if dist > (max_dribble_length - max_dribble_error_margin): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be (dist-max_dribble_length) > max_dribble_error_margin?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think its correct right now since it states earlier in the file that this is a margin for a conservative estimate for allowed dribble distance, so it should make the allowed distance shorter to make sure we dont go over the strict limit.
| """Checks if any friendly robot is excessively dribbling the ball, i.e. for over 1m.""" | ||
|
|
||
| def __init__(self): | ||
| self.continous_dribbling_start_point = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this line still useful? The usage of continous_dribbling_start_point seems to be completely removed in this PR.
Description
Testing Done
Resolved Issues
Resolves #3452
Length Justification and Key Files to Review
Review Checklist
It is the reviewers responsibility to also make sure every item here has been covered
.hfile) should have a javadoc style comment at the start of them. For examples, see the functions defined inthunderbots/software/geom. Similarly, all classes should have an associated Javadoc comment explaining the purpose of the class.TODO(or similar) statements should either be completed or associated with a github issueAdditional Comments
Not really an addition and more of a few observations and questions. Wanted to still make this PR since I feel like it's not directly related to my current ticket (and also because I've dragged this on for too long lol).
Was looking at how the Autoref implemented dribble distance, and from what I understood it seems to compare initial position of the robot to the final position of the ball (see the code snippet below, taken from https://github.com/TIGERs-Mannheim/AutoReferee/tree/53063578e38ac4818849df3196b32a856a5fa41d). If I'm mistaken, please tell me and I'll edit the comments in my branch lol
Sorry if that was a bit unclear, please let me know if it was. Thanks!