Exemple #1
0
                       rightFoot, farNegativeYaw, farPositiveYaw, lookAtBall2,
                       seeGoal)

#create states

rotateLeftState = createState("rotateLeftState",
                              lambda: setWalkVelocity(0, 0, 0.15))
rotateRightState = createState("rotateRightState",
                               lambda: setWalkVelocity(0, 0, -0.15))
archLeftState = createState("archLeftState",
                            lambda: setWalkVelocity(0.65, 0, 0.15))
archRightState = createState("archRightState",
                             lambda: setWalkVelocity(0.65, 0, -0.15))
walkToBallState = createState("walkToBallState",
                              lambda: setWalkVelocity(0.6, 0, 0))
watchBallState = createState("watchBallState", lambda wm: lookAtBall2(wm))
stopWalkingState = createState("stopWalkingState", stopWalking)
stopWalkingState2 = createState("stopWalkingState2", stopWalking)
setBottomCamState = createState("setBottomCamState",
                                lambda: setCamera("bottom"))
setBottomLedState = createState("setBottomLedState",
                                lambda: setLED("eyes", 1, 0, 0))
kickRightState = createState("kickRightState", lambda: kick("right"))
kickLeftState = createState("kickLeftState", lambda: kick("left"))

# FSM for following the ball

goToBallFSM = createFSM("goToBallFSM")
addStates(goToBallFSM, rotateLeftState, rotateRightState, walkToBallState,
          watchBallState, stopWalkingState, stopWalkingState2,
          setBottomLedState, setBottomCamState, kickRightState, kickLeftState,
    say, setLED, setWalkVelocity, stopWalking)

# Import functions we've written
from functions import (seeBall, noSeeBall, shakeHeadTime, largestBall,
    averageLook, lookAtBall, rotateTime, entryTime, currentTime, 
    cameraDelay, headTurning, lookAtBall2)


#Create States

shakeHeadState = createState("shakeHeadState", lambda wm: headTurning(wm))
shakeHeadState2 = createState("shakeHeadState2", lambda wm: headTurning(wm))
setTopCameraState = createState("setTopCameraState", lambda : setCamera("top"))
setBottomCameraState = createState("setBottomCameraState", lambda : setCamera("bottom"))
setTopCameraState2 = createState("setTopCameraState2", lambda : setCamera("top"))
lookAtBallState = createState("lookAtBallState", lambda wm : lookAtBall2(wm))
rotateState = createState("rotateState", lambda : setWalkVelocity(0, 0, 0.5))
bottomLedState = createState("bottomLedState", lambda : setLED("eyes", 1, 0, 0)) # Red
topLedState = createState("topLedState", lambda : setLED("eyes", 0, 1, 0)) # Green
topLedState2 = createState("topLedState2", lambda : setLED("eyes", 0, 1, 0)) # Green
stopWalkState = createState("stopWalkState", stopWalking)


# FSM for searching for the ball

lookBallFSM = createFSM("lookBallFSM")
addStates(lookBallFSM, shakeHeadState, stopWalkState,
          setTopCameraState, setTopCameraState2, 
          setBottomCameraState, bottomLedState,
          topLedState, lookAtBallState, rotateState,
          shakeHeadState2,topLedState2)