Skip to content

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

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open

Conversation

zuperzane
Copy link
Contributor

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

  • [Pretty sure ] Remove all commented out code
  • [Believe so ] Remove extra print statements: for example, those just used for testing
  • [I think so ] Resolve all TODO's: All TODO (or similar) statements should either be completed or associated with a github issue

Maybe 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.


DefensePlayFSM::DefensePlayFSM(TbotsProto::AiConfig ai_config)
: DefensePlayFSMBase::DefensePlayFSMBase(ai_config)
{
}

void DefensePlayFSM::defendAgainstThreats(const Update& event)
bool DefensePlayFSM::shouldDefendAggressively(const Update& event)
Copy link
Contributor

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;
Copy link
Contributor

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

Comment on lines +68 to +70
// 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
Copy link
Contributor

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(),
Copy link
Contributor

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()

Copy link
Contributor Author

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

Copy link
Contributor

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

Comment on lines +160 to +161
auto pull_to_here =
(event.common.robot.position() - ball_position) * 2 + ball_position;
Copy link
Contributor

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?

Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Contributor

@itsarune itsarune left a 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement a new ShadowEnemyTactic
2 participants