-
Notifications
You must be signed in to change notification settings - Fork 111
Shadow Defense Base #3450
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?
Shadow Defense Base #3450
Conversation
Co-authored-by: William Ha <[email protected]>
Co-authored-by: William Ha <[email protected]>
…e and turn it to a shadower
…er is always confident that someone has ball, also adding a simple test that is to be fixed
…e threshold for is near dribble
…t going to remove it for now and see if tests pass
|
||
DefensePlayFSM::DefensePlayFSM(TbotsProto::AiConfig ai_config) | ||
: DefensePlayFSMBase::DefensePlayFSMBase(ai_config) | ||
{ | ||
} | ||
|
||
void DefensePlayFSM::defendAgainstThreats(const Update& event) | ||
bool DefensePlayFSM::shouldDefendAggressively(const Update& event) |
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.
lmao why have this check at all?
LOG(WARNING) << "Enemy threat not initialized for robot " << event.common.robot.id() | ||
<< "\n"; | ||
bool near_ball = distance(event.common.world_ptr->ball().position(), | ||
enemy_threat_opt.value().robot.position()) < 0.22; |
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.
avoid magic numbers. You should use a constant. See the code style guide: https://github.com/UBC-Thunderbots/Software/blob/master/docs/code-style-guide.md
src/software/ai/hl/stp/tactic/shadow_enemy/shadow_enemy_fsm.cpp
Outdated
Show resolved
Hide resolved
// OK so basically you need to change thresholds for how close | ||
////in robot.h there is a isneardribbler function u can use instead of this breakbeams | ||
/// stuff |
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.
stray comment
// OK so basically you need to change thresholds for how close | ||
////in robot.h there is a isneardribbler function u can use instead of this breakbeams | ||
/// stuff | ||
bool robot_contesting = distance(event.common.world_ptr->ball().position(), |
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.
why not use event.common.robot.isNearDribbler()
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 it was due to me not wanting to change the code for the is near dribbler because I think it always undershot the ball but it's probably a good idea, also do u know if we are gonna have the brake beam be added cuz that would be like so cool to have here as a condition instead of having to rely on vision which would be pretty bad especially with robots fighting
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.
isNearDribbler
has an optional tolerance threshold you can pass, so you can make it tighter just for this code (i.e. you can call event.common.robot.isNearDribbler(ball_position, 0.22)
)
#3344 is an issue that's tracking breakbeam status. I am not sure if @Andrewyx is currently working on it, but if you have time, you can try asking to work on it
auto pull_to_here = | ||
(event.common.robot.position() - ball_position) * 2 + ball_position; |
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.
why do we need both goAndSteal
AND stealAndPull
?
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 also can't really tell where we are trying to move the ball to, I think you should add some document explaining where we're trying to move the ball
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.
you should port this to a tactic pytest. This is a pytest that tests specifically only the tactic whereas defense_play_test
tests the entire play.
Here's an example of what one would look like: https://github.com/UBC-Thunderbots/Software/blob/master/src/software/ai/hl/stp/tactic/crease_defender/crease_defender_tactic_test.py
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.
awesome! defense looks way better now!
Corner fix Co-authored-by: itsarune <[email protected]>
resolves #3357
Testing involves a py test added to defense test and a shadow fsm test
Resolved defense lack of aggressiveness
[x]New Tests
[x]New Tactic
[ ]Unable to test in real life, possible when robots free
TODO
(or similar) statements should either be completed or associated with a github issueMaybe make another TODO that has to do with editing the function on line 15
in src/software/ai/hl/stp/play/defense/defense_play_fsm.cpp
It should make a better decision as to when to start acting like a shadower vs just always taking any passing defender and as soon as they're between the ball and the net acting like shadower. Maybe if it also had nobody to pass to or nowhere to go I'm not sure I could do that for this todo if that makes more sense tho.