-
Notifications
You must be signed in to change notification settings - Fork 29
/
SquatGameStates.py
75 lines (63 loc) · 2.32 KB
/
SquatGameStates.py
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
import man.motion.SweetMoves as SweetMoves
def gameInitial(player):
"""
Ensure we are sitting down and head is snapped forward.
In the future, we may wish to make the head move a bit slower here
Also, in the future, gameInitial may be responsible for turning off the gains
"""
if player.firstFrame() and not player.squatting:
player.stopWalking()
player.gainsOn()
player.zeroHeads()
player.GAME_INITIAL_satDown = False
elif player.brain.nav.isStopped() and not player.GAME_INITIAL_satDown and\
not player.squatting:
player.GAME_INITIAL_satDown = True
player.executeMove(SweetMoves.SIT_POS)
return player.stay()
def gameReady(player):
"""
Stand up, and pan for localization
"""
player.standup()
player.brain.tracker.locPans()
if player.lastDiffState == 'gameInitial':
return player.goLater('relocalize')
if player.firstFrame() and \
player.lastDiffState == 'gamePenalized':
player.brain.resetLocalization()
return player.goLater('squatPosition')
def gameSet(player):
player.brain.resetGoalieLocalization()
if player.squatting:
return player.goLater('squatted')
return player.goLater('squat')
def gamePlaying(player):
if player.squatting:
return player.goLater('squatted')
return player.goLater('squat')
def gameFinished(player):
"""
Ensure we are sitting down and head is snapped forward.
In the future, we may wish to make the head move a bit slower here
Also, in the future, gameInitial may be responsible for turning off the gains
"""
if player.squatting:
player.executeMove(SweetMoves.GOALIE_SQUAT_STAND_UP)
player.squatting = False
if player.firstFrame():
player.zeroHeads()
player.GAME_FINISHED_satDown = False
return player.stay()
# Sit down once we've finished walking
if player.brain.nav.isStopped() and not player.GAME_FINISHED_satDown:
player.GAME_FINISHED_satDown = True
player.executeMove(SweetMoves.SIT_POS)
return player.stay()
if not player.motion.isBodyActive() and player.GAME_FINISHED_satDown:
player.gainsOff()
return player.stay()
def gamePenalized(player):
if player.firstFrame():
player.penalizeHeads()
return player.stay()