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

EnemyFreeKickPlay FSM Conversion #3179

Merged
merged 70 commits into from
Jun 2, 2024

Conversation

Andrewyx
Copy link
Contributor

@Andrewyx Andrewyx commented Apr 4, 2024

Please fill out the following before requesting review on this PR

Description

This PR addresses the EnemyFreeKickPlay redesign in which we transform the existing design utilizing co-routines into the current FSM framework.

NOTE: This PR contains a stopgap redesign of DefensePlayFSM to suit the case of EnemyFreeKickPlayFSM. This PR shares significant similarities with DefensePlayFSM and is planned to be refactored along with DefensePlayFSM in a following PR.

Otherwise same behaviour as DefensePlayFSM, but:

  1. Only 1 pass defender allowed to guard enemy kicker (Main Pass Defender)
  2. Robots obey standard 0.5m obstacle radius around ball per Free Kick rules,
    this implementation uses 0.6m to better avoid violation area
  3. All redundant pass defenders X meters around the main pass defender are skipped to ensure we do not have duplicate assignments too close to one another (this "skip region" set to a radius of 3m of the Main Pass
  4. Introduces new Mid Point defender to guard mid region between the ball and net in cases when large gap exists

Other Changes:

  • Uses Suchir's OrValidation from Pytest validation #3123
  • Implements new ball_moves_from_rest validation to check when the ball is moved per the RoboCup 0.05m standards.

enemyFreeKick-ezgif com-video-to-gif-converter

Testing Done

Pytests have been written to test behaviour. This can be run with ./tbots.py run enemy_free_kick_play_test.py -o -t

KNOWN BUGS: FIXED
- If the Main Pass Defender switches roles, it may cut through the foul region,
this will be most likely fixed in the new dynamic trajectory planner PR #3152

Resolved Issues

Resolves #3011, Re-implements #2970

Length Justification and Key Files to Review

This PR is broken up into two PRs, this one focuses on the implementation of the FSM. A future PR will be used to refactor EnemyFreeKickPlayFSM and DefensePlayFSM and abstract away shared functionality.

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

Andrewyx and others added 30 commits January 27, 2024 14:03
Copy link
Contributor

@raymond212 raymond212 left a comment

Choose a reason for hiding this comment

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

Looks great! I just left a few minor comments about variable/constant names.


DEFINE_PLAY_UPDATE_STRUCT_WITH_CONTROL_AND_COMMON_PARAMS

static constexpr double THRESHOLD_DISTANCE_METERS = 0.1;
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps a name like TOO_CLOSE_THRESHOLD_METERS would better?

Comment on lines 66 to 70
DEFINE_SML_STATE(BlockFreeKicker)

DEFINE_SML_EVENT(Update)

DEFINE_SML_ACTION(setupEnemyKickerStrategy)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
DEFINE_SML_STATE(BlockFreeKicker)
DEFINE_SML_EVENT(Update)
DEFINE_SML_ACTION(setupEnemyKickerStrategy)
DEFINE_SML_STATE(BlockEnemyKickerState)
DEFINE_SML_EVENT(Update)
DEFINE_SML_ACTION(blockEnemyKicker)

An FSM state should usually include State in the name, to distinguish it from an action.

The action setupEnemyKickerStrategy is a bit confusing, something like blockEnemyKicker could be more clear.

@Andrewyx Andrewyx requested a review from raymond212 May 20, 2024 06:58
raymond212
raymond212 previously approved these changes May 25, 2024
Copy link
Contributor

@raymond212 raymond212 left a comment

Choose a reason for hiding this comment

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

👍

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.

The changes look great in Thunderscope! Just had a small nit

@@ -3,7 +3,7 @@
#include <g3sinks/LogRotate.h>
#include <g3sinks/LogRotateWithFilter.h>

#include <experimental/filesystem>
//#include <experimental/filesystem>
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you forgot to uncomment the lines in this file

Comment on lines 85 to 88
if (!std::experimental::filesystem::exists(runtime_dir))
{
std::experimental::filesystem::create_directories(runtime_dir);
}
// if (!std::experimental::filesystem::exists(runtime_dir))
// {
// std::experimental::filesystem::create_directories(runtime_dir);
// }
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nuts I forgot to recomment that when I went in to fix the bad merge. Should be fixed now thought

nimazareian
nimazareian previously approved these changes May 30, 2024
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.

LGTM ⚽

Copy link
Contributor

@raymond212 raymond212 left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@raymond212 raymond212 left a comment

Choose a reason for hiding this comment

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

I merged EnemyBallPlacementPlay #3146 into master, and there seems to be some merge conflicts with this PR.

@Andrewyx Andrewyx requested a review from raymond212 June 1, 2024 19:29
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.

Praying that CI passes 🙏

Copy link
Contributor

@raymond212 raymond212 left a comment

Choose a reason for hiding this comment

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

Looks good!

@Andrewyx Andrewyx merged commit 35c1b32 into UBC-Thunderbots:master Jun 2, 2024
6 checks passed
@Andrewyx Andrewyx self-assigned this Jun 5, 2024
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.

We should track enemy robots and try to block their shots during freekicks
4 participants