Skip to content

[Cont'd] Improved ball placement from RoboCup 2024#3597

Open
Apeiros-46B wants to merge 51 commits intoUBC-Thunderbots:masterfrom
Apeiros-46B:ball_placement
Open

[Cont'd] Improved ball placement from RoboCup 2024#3597
Apeiros-46B wants to merge 51 commits intoUBC-Thunderbots:masterfrom
Apeiros-46B:ball_placement

Conversation

@Apeiros-46B
Copy link
Copy Markdown
Member

@Apeiros-46B Apeiros-46B commented Feb 11, 2026

Description

Continuation of #3447

Ball placement play by @mkhlb from RoboCup 2024.
Comments regarding ball placement play from #3415 have been addressed.

Fixes flaky ball placement tests; these were because there was some kind of race condition when the gamecontroller commands are sent from the test fixture to the C++ code where the world_ptr.gameState()->.getBallPlacementPoint() sometimes was the expected placement point for the previous test case.

Testing Done

Resolved Issues

Resolves #3561

Length Justification and Key Files to Review

  • ball_placement_play_fsm.cpp
  • ball_placement_play_fsm.h
  • ball_placement_play_fsm_test.cpp
  • ball_placement_play_test.py

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

mkhlb and others added 30 commits June 4, 2024 18:41
… ball placement go back to aligning when ball is lost
…_testing_june_4

# Conflicts:
#	src/software/ai/hl/stp/play/ball_placement/ball_placement_play_fsm.h
williamckha and others added 8 commits March 8, 2025 13:57
…into ball_placement

# Conflicts:
#	src/software/ai/hl/stp/play/ball_placement/ball_placement_play_fsm.cpp
#	src/software/ai/hl/stp/play/ball_placement/ball_placement_play_fsm.h
#	src/software/ai/hl/stp/play/ball_placement/ball_placement_play_fsm_test.cpp
#	src/software/ai/hl/stp/tactic/dribble/dribble_tactic.cpp
Comment on lines +16 to +17
// Subtract b from a, or return 0 if b is larger than a
static unsigned int subSat(unsigned int a, unsigned int b)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Should this be moved to another file?

* Exclude goalie from placing robot selection
* Remember setup angle and check alignment in alignDone
* Add ballLost check
* Move friendly robots out of the way when setting up move tactics
* "fix" robot bumping ball when retreating
* check velocity in align guards
* remember placing robot ID to prevent oscillation
* temporary friendly robot safe zone logic (need to fix later since rn it goes into goals)
* The fix is slightly suboptimal and relies on a hardcoded fix, will
  investigate better options soon
@Andrewyx
Copy link
Copy Markdown
Contributor

Andrewyx commented Apr 7, 2026

@Apeiros-46B What is the progress on this ticket?

@Apeiros-46B
Copy link
Copy Markdown
Member Author

The test flakiness is fixed, there's just one last issue with the waiting line placement and robot reassignment. I have a fix but it's not perfect (but might be good enough I'm not sure), I will push the changes when I get home

@Apeiros-46B Apeiros-46B marked this pull request as ready for review April 8, 2026 23:37
# ball placement position. This prevents the issue where subsequent test
# runs don't properly get the ball placement point set properly and reuse
# the target point from the previous test case.
time.sleep(0.5)
Copy link
Copy Markdown
Member Author

@Apeiros-46B Apeiros-46B Apr 8, 2026

Choose a reason for hiding this comment

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

If there's some a more reliable way to wait until the first command is acknowledged, that would be more ideal, but for now this does fix the test flakiness

return {facing_angle, backoff_point};
}

void BallPlacementPlayFSM::setupMoveTactics(const Update& event, unsigned int num_tactics)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm not sure if the current waiting line positioning is ideal

* @param b the right-hand side
* @return a - b, or 0 if it would underflow
*/
static unsigned int subSat(unsigned int a, unsigned int b)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

should this helper be moved somewhere else?

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.

Fix flaky ball placement tests

5 participants