-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo_referee_gui_rsim.py
More file actions
76 lines (62 loc) · 2.65 KB
/
Copy pathdemo_referee_gui_rsim.py
File metadata and controls
76 lines (62 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
"""demo_referee_gui_rsim.py — CustomReferee + web GUI + StrategyRunner (RSim).
Run:
pixi run python demo_referee_gui_rsim.py
# RSim window opens; open http://localhost:8080 in a browser
What it does:
- Creates a CustomReferee (human profile) with enable_gui=True so the
browser panel starts automatically.
- Passes the referee to StrategyRunner via referee=. StrategyRunner
calls referee.step() on every tick and handles ball teleports on STOP
automatically — no patching required.
- WanderingStrategy is used as the base strategy so robots visibly move and
you can watch the RefereeOverride tree interrupt them when you issue
commands from the GUI (Halt, Kickoff Yellow, etc.).
Operator workflow:
1. Open http://localhost:8080 in a browser.
2. Robots start moving under WanderingStrategy.
3. Click any command button (Halt, Stop, Kickoff Yellow…) — robots reposition.
4. Click Normal Start to resume free play.
5. With the human profile, the referee stays in STOP after a goal until the operator advances play.
"""
from utama_core.custom_referee import CustomReferee
from utama_core.custom_referee.profiles.profile_loader import load_profile
from utama_core.run import StrategyRunner
from utama_core.tests.referee.wandering_strategy import WanderingStrategy
# ---------------------------------------------------------------------------
# Configuration
# ---------------------------------------------------------------------------
PROFILE = "human" # "human" or "simulation"
GUI_PORT = 8080
N_ROBOTS = 3 # robots per side
MY_TEAM_IS_YELLOW = True
MY_TEAM_IS_RIGHT = True
# ---------------------------------------------------------------------------
# Entry point
# ---------------------------------------------------------------------------
def main() -> None:
profile = load_profile(PROFILE)
# enable_gui=True starts the HTTP server in a background daemon thread.
# referee.step() is called by StrategyRunner on every tick; the GUI
# receives state automatically after each call.
referee = CustomReferee(
profile,
n_robots_yellow=N_ROBOTS,
n_robots_blue=N_ROBOTS,
enable_gui=True,
gui_port=GUI_PORT,
)
runner = StrategyRunner(
strategy=WanderingStrategy(),
my_team_is_yellow=MY_TEAM_IS_YELLOW,
my_team_is_right=MY_TEAM_IS_RIGHT,
mode="rsim",
control_scheme="pid",
exp_friendly=N_ROBOTS,
exp_enemy=N_ROBOTS,
referee=referee, # StrategyRunner drives referee.step() each tick
show_live_status=True,
opp_strategy=WanderingStrategy(),
)
runner.run()
if __name__ == "__main__":
main()