-
Notifications
You must be signed in to change notification settings - Fork 113
Improve FreeKickPlay behaviour and convert it to use FSMs #2953
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
Improve FreeKickPlay behaviour and convert it to use FSMs #2953
Conversation
…rav_banna/pass_speed_cost � Conflicts: � src/software/thunderscope/thunderscope.py
…rav_banna/pass_speed_cost
…rav_banna/pass_speed_cost
…rav_banna/pass_speed_cost � Conflicts: � src/software/ai/hl/stp/tactic/kick/kick_fsm.cpp
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.
LGTM one comment
// Passing robot | ||
updateAlignToBallTactic(event.common.world_ptr); | ||
tactics_to_run[0].emplace_back(align_to_ball_tactic); | ||
|
||
if (event.common.num_tactics <= 1) | ||
{ | ||
LOG(WARNING) | ||
<< "Not enough tactics to setup pass receivers and defenders during free kick"; | ||
return; | ||
} |
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 align_to_ball_tactic
will not get set if we have num_tactics == 1
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.
Yeah you're right. I decided to just remove the check. setReceiverAndDefenderTactics
already can handle the case where num_tactics = 1
. Though If num_tactics = 1
, we just chip it towards the center and run towards it since there are no defenders. I hope we won't have to test that in real life 😅
double abs_min_pass_score = | ||
ai_config.shoot_or_pass_play_config().abs_min_pass_score(); | ||
double min_perfect_pass_score = | ||
ai_config.shoot_or_pass_play_config().min_perfect_pass_score(); |
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.
What is the plan here for when #3246 is merged in? I believe ShootOrPassPlayConfig is going to be removed and replaced with ShotConfig, which is very different.
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.
Both PRs are being aimed to be merged with master, so which ever one is merged second will need to fix it. I can't update this PR to use ShotConfig
, since it doesn't exist on my branch.
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.
LGTM
// Note that getBestReceivingPositions may return fewer positions than requested | ||
// if there are not enough robots, so we will need to check the size of the vector. |
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.
isn't it guaranteed to be exactly num_tactics? since receiver_positioning_tactics
is resized to num_tactics
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.
We actually update num_tactics
to be a valid number within getBestReceivingPositions
.
Software/src/software/ai/passing/receiver_position_generator.hpp
Lines 141 to 152 in 2b91689
// Verify that the number of receiver positions requested is valid | |
if (num_positions > | |
(world.friendlyTeam().numRobots() - existing_receiver_positions.size())) | |
{ | |
LOG(WARNING) << "Not enough friendly robots to assign " << num_positions | |
<< " receiver positions. Assigning " | |
<< world.friendlyTeam().numRobots() - | |
existing_receiver_positions.size() | |
<< " receiver positions instead"; | |
num_positions = static_cast<unsigned int>(world.friendlyTeam().numRobots() - | |
existing_receiver_positions.size()); | |
} |
// Face towards the center of the left segment of the enemy defense area, | ||
// so we are prepared to take a shot on enemy net, or pass the ball near | ||
// the enemy defense area. |
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 specifically the negative x negative y corner and not just the enemy goal centre?
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.
This is similar to the one of the changes that Andrew had in his CreaseDefender PR. We're getting the center of the left segment of the defense area, and not the center of the defense area.
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 specifically choose that segment?
/** | ||
* Guard on whether to abort the pass | ||
* | ||
* @param event the ShootOrPassPlayFSM 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.
* @param event the ShootOrPassPlayFSM Update event | |
* @param event the FreeKickPlayFSM 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.
Updated
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.
looks good, minor nit
// The distance that the ball has to travel for it to be considered in play | ||
// after a kick-off, free kick, or penalty kick. | ||
// https://robocup-ssl.github.io/ssl-rules/sslrules.html#_ball_in_and_out_of_play | ||
static const double BALL_IN_PLAY_DISTANCE_THRESHOLD_METERS = 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.
in the future, we can probably use this constant in game_state.cpp
. It's a good first member ticket
/** | ||
* Updates the kicker to align to the ball | ||
* | ||
* @param world the latest world |
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:
* @param world the latest world | |
* @param world_ptr the latest world |
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.
feel free to merge 🥳
Description
❗ This PR is dependent on the changes from #3200, as such, it's in a draft state until that is merged. Please comment any passing/receiving related suggestions in that PR and for the time being only focus on suggestions around the changes listed below in this PR.Improved FreeKickPlay:
Reimplemented it using FSMs
Used KickTactic instead of AttackerTactic to ensure that we do not dribble
Deleted
CornerKickPlay
Update
KickFSM
andChipFSM
to make sure that the robot is aligned to the kick/chip direction of the latest control params. Also update how far we drive into the ball.Update


GetBehindBallFSM
's guard to be more strict on the robot's alignment with the ball. The width of the region has been updated to have the same tolerance that the ball has to be within for it to not hit the side of the dribbler.Old region that the robot had to be within to be counted as "behind ball":
Updated region:
Update some of the constants related to the robots based on the most up to date CAD.
Todo:
Testing Done
Tried free kicks in AI vs AI and updated existing tests
Resolved Issues
resolves #2950, resolves #3205
Length Justification and Key Files to Review
free_kick_play_fsm.h
andfree_kick_play_fsm.cpp
.Review Checklist
It is the reviewers responsibility to also make sure every item here has been covered
.h
file) 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 issue