Skip to content
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

Draft
wants to merge 26 commits into
base: master
Choose a base branch
from

Conversation

raymond212
Copy link
Contributor

@raymond212 raymond212 commented Jun 30, 2023

Please fill out the following before requesting review on this PR

Description

Improved FreeKickPlay:

  1. Reimplemented it using FSMs
  2. Used KickTactic instead of AttackerTactic to ensure that we do not dribble
  3. Deleted CornerKickPlay

Todo:

  • Add validation for free kick play

Testing Done

Resolved Issues

resolves #2950, resolves #3205

Length Justification and Key Files to Review

free_kick_play_fsm.h and free_kick_play_fsm.cpp.

Review Checklist

It is the reviewers responsibility to also make sure every item here has been covered

  • Function & Class comments: All function definitions (usually in the .h file) should have a javadoc style comment at the start of them. For examples, see the functions defined in thunderbots/software/geom. Similarly, all classes should have an associated Javadoc comment explaining the purpose of the class.
  • Remove all commented out code
  • Remove extra print statements: for example, those just used for testing
  • Resolve all TODO's: All TODO (or similar) statements should either be completed or associated with a github issue

Copy link
Contributor

@williamckha williamckha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet

Comment on lines 16 to 23
/**
* This play is basically:
* - One robot attempts to shoot first. If there is no good shot, it will attempt to
* pass, and finally chips towards the enemy goal if it can't find a pass in time
* - Two robots try to get in good positions near the enemy net to receive a pass
* - Two robots crease defend
* - One robot is goalie
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should include this comment at the top of free_kick_play.h since this function might be removed later

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment on lines 18 to 20
MAX_TIME_TO_COMMIT_TO_PASS(Duration::fromSeconds(
5)), // Spend at most 5 seconds looking for a pass. The rule for division B
// teams is at most 10 seconds spent on the entire free kick
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we might want to make this a configurable param in parameters.proto

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 this parameter is quite specific to free kick, so it might be fine to just declare it in FreeKickPlayFSM.h as a static const.

Comment on lines 18 to 23
MAX_TIME_TO_COMMIT_TO_PASS(Duration::fromSeconds(
5)), // Spend at most 5 seconds looking for a pass. The rule for division B
// teams is at most 10 seconds spent on the entire free kick
MIN_ACCEPTABLE_PASS_SCORE(0.1),
MIN_OPEN_ANGLE_FOR_SHOT(
5) // Only attempt shots with an opening angle greater than 5 degrees
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for these constants, i'd prefer them to be declared as static const and declared directly in the header file. I believe there are some compiler optimizations to doing constants in that way

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@nimazareian nimazareian mentioned this pull request Jul 3, 2023
4 tasks
williamckha
williamckha previously approved these changes Jul 3, 2023
@nimazareian
Copy link
Contributor

nimazareian commented Oct 6, 2023

@raymond212 is this PR still good to be merged (not sure if we changed this on the robocup branch)? Is it implemented the way we want it? (cc: @itsarune @williamckha)

@raymond212
Copy link
Contributor Author

raymond212 commented Oct 7, 2023

@nimazareian This PR will probably get somewhat overhauled when we rewrite our gameplay architecture but it definitely improves upon the current implementation and I think it can be merged for now.

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.

LGTM, minor nit

Copy link
Contributor

@nimazareian nimazareian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skimmed through the changes and it looks good. Just pending Arun's comment and the failing CI (fixed once you pull upstream master)

chip_tactic(std::make_shared<ChipTactic>()),
passer_tactic(std::make_shared<KickTactic>()),
receiver_tactic(std::make_shared<ReceiverTactic>()),
offensive_positioning_tactics(std::vector<std::shared_ptr<MoveTactic>>(2)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not blocking this merge but I think free kick play FSM is only handling two robot behaviour atm (can be fixed later) Or am I wrong?

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.

I tested it on my computer and it seems that during the free kick process, several robots are being assigned a StopTactic. I don't think that is ideal.

@nimazareian
Copy link
Contributor

@raymond212 What's the status of this PR? Do you think you could update it? I think it could be nice to get it in and not wait on the gameplay overhaul since we don't have an exact timeline on that. What do you think @itsarune?

@raymond212 raymond212 marked this pull request as draft May 19, 2024 18:44
@nimazareian
Copy link
Contributor

@raymond212 Once this PR is ready, similar to to #3146, could you also include some videos of what the new gameplay looks like?

@raymond212
Copy link
Contributor Author

@raymond212 Once this PR is ready, similar to to #3146, could you also include some videos of what the new gameplay looks like?

Yes, I'll be sure to do that.

DribblingParcourPlay = 21;
ScoringFromContestedPossessionPlay = 22;
PassEndurancePlay = 23;
ShootOrPassPlay = 5;
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 reserve 5 and keep the existing proto numbers so that we don't break previous replays

class FreeKickPlay : public Play
{
public:
FreeKickPlay(TbotsProto::AiConfig config);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the constructor should have docs


shoot_tactic->updateControlParams(
ball_pos, (shot->getPointToShootAt() - ball_pos).orientation(),
BALL_MAX_SPEED_METERS_PER_SECOND - 0.5);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should refactor attacker_tactic instead to add the padding within attacker tactic.

my concern: sometime in the future, we decide we want to lower/increase the shot speed and we have to find all instances of attacker tactic performing a shot and change it which isn't maintainable.

LOG(DEBUG) << "Time to look for pass expired. Chipping ball...";
PriorityTacticVector tactics_to_run = {{}};

double fallback_chip_target_x_offset = 1.5;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe this should be a static constexpr

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you supplement the these tests to demonstrate free kicks shooting & chipping as well?

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.

looking good 🔥!

It still seems some defenders seem to be assigned StopTactics unintentionally. Let's try to explicitly assign robots to all tactics

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

Successfully merging this pull request may close these issues.

Delete CornerKickPlay [Gameplay] Fix FreeKickPlay and convert it into using FSMs
5 participants