Skip to content

Automate handling referee game events#3643

Merged
nycrat merged 20 commits intoUBC-Thunderbots:masterfrom
nycrat:avah/automate_manual_referee_commands
Mar 15, 2026
Merged

Automate handling referee game events#3643
nycrat merged 20 commits intoUBC-Thunderbots:masterfrom
nycrat:avah/automate_manual_referee_commands

Conversation

@nycrat
Copy link
Member

@nycrat nycrat commented Mar 11, 2026

Description

Adds an __automate_referee method to the gamecontroller binary context manager class that handles referee game events for POSSIBLE_GOAL and FAILED_PLACEMENT. This automates two common human referee interventions so that the game will continue by itself.

  • For a possible goal, automatically approves it and start ball placement to (0,0)
  • For a failed placement, send a world state message with the ball teleported to the placement point

Testing Done

Ran ./tbots.py run thunderscope_main --enable_autoref (uncommented __automate_referee method call) and:

  • Triggered possible goal event manually using gamecontroller UI, the goal was approved and ball placement started, the robots continued playing
  • Waited until a goal was naturally scored, it was approved and same behaviour... robots kept playing
  • Triggered ball placement with gamecontroller UI, then placed ball in corner with thunderscope, the team failed to place ball, then it was moved automatically to the placement position
  • Waited for ball placement from the autoref, then placed ball in corner, same behaviour... still works
approve_goal.mov
placement_failed.mov

Resolved Issues

Part of #3633, resolves #3625

Length Justification and Key Files to Review

N/A

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

@nycrat nycrat closed this Mar 12, 2026
@nycrat nycrat force-pushed the avah/automate_manual_referee_commands branch from 4c8dcbb to 0de03a7 Compare March 12, 2026 05:26
@nycrat nycrat reopened this Mar 12, 2026
@nycrat nycrat force-pushed the avah/automate_manual_referee_commands branch from 835ac60 to b9df062 Compare March 12, 2026 06:06
@nycrat nycrat changed the title Automate referee commands in record_stats mode Automate handling referee game events Mar 13, 2026
@nycrat nycrat marked this pull request as ready for review March 13, 2026 22:25
@nycrat nycrat requested a review from StarrryNight March 13, 2026 22:36
Andrewyx
Andrewyx previously approved these changes Mar 15, 2026
@GrayHoang GrayHoang self-requested a review March 15, 2026 00:47
Copy link
Contributor

@GrayHoang GrayHoang left a comment

Choose a reason for hiding this comment

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

lgtm

@nycrat nycrat merged commit 5e0160f into UBC-Thunderbots:master Mar 15, 2026
6 checks passed
StarrryNight pushed a commit that referenced this pull request Mar 21, 2026
* Implement auto approving goals

* Re-write code to be a bit cleaner

* Re-initialize world state after ball placement failure

* Make sure teams get reset with proper amount of robots

* Set only ball to ball placement point when failed

* Remove unused import

* Separate automate_referee method into helpers

* Add comments

* Implement auto start second half

* Add call to automate_stage_change

* Fix copying enum

* Refactor method a bit

* Implement starting new game

* Uncomment call to automate_referee, move after updating latest world

* Refactor a bit

* Extract helper function for handling stage change

* Add doc comment

* Let both teams do ball placement before manual placement

* Get rid of magic number
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.

Autoref automate Manual Ball Placement

3 participants