Example #1
0
def ReturnField():
    global phase
    if mot.isWalking():
        # ..search for a ball
        if vis.scanCircle(visThread, 0.2):
            phase = 'BallFound'
    else:
        phase = 'BallNotFound'
Example #2
0
def Set():
    global control
    global teamColor
    global kickOff
    global phase
    global firstCall
    control = [0,0,0]
    # if the first iteration
    if firstCall['Set']:
        
        # update info about team, it is possible that game is started in set phase
        (teamColor, kickOff, penalty) = sc.getMatchInfo()    
        
        print 'In set state'
        visThread.startScan()                           # start ballscan

        print 'TeamColor: ' , teamColor                 # print teamcolor as a check
        
        # Initial pose, if not already in it
        mot.stiff()
        if playerType == 0:
            mot.normalPose()
        else:
            mot.keepNormalPose()
        
        audProxy.setOutputVolume(0)                     # set volume to zero    
        ledProxy.fadeRGB('ChestLeds', 0x00ffff00, 0)    # set chestledcolor to green
        
        # Team color must be displayed on left foot (Reference to rules)
        if (teamColor == 0):
            ledProxy.fadeRGB('LeftFootLeds', 0x000000ff, 0)
        else:
            ledProxy.fadeRGB('LeftFootLeds', 0x00ff0000, 0)
        
        firstCall['Initial']   = True   
        firstCall['Ready']     = True
        firstCall['Set']       = False
        firstCall['Playing']   = True
        firstCall['Penalized'] = True

    # Head movements allowed in the set state
    # FIND A BALL #
    if phase != 'BallFound' and phase != 'BallFoundKeep':
        if vis.scanCircle(visThread, 0.2):
            if playerType == 0:
                phase = 'BallFound'
            else:
                phase = 'BallFoundKeep'

    # Keep finding the ball, it might move (or does it?)
    if not(visThread.findBall()):
            if playerType == 0:
                phase = 'BallNotFound'
            else:
                phase = 'BallNotFoundKeep'
Example #3
0
def BallNotFoundKeep():
    global phase
    global ball_loc
    
    # if a ball is found
    if vis.scanCircle(visThread, 0.2):
        # reinitialize
        ball_loc = dict()
        phase = 'BallFoundKeep'
        firstCall['BallNotFoundKeep'] = True
    elif firstCall['BallNotFoundKeep']:
        memProxy.insertData('dntBallDist', 0)
        mot.keepNormalPose()
        firstCall['BallNotFoundKeep'] = False
Example #4
0
def BallNotFound():
    global ball_loc
    global phase
    global control
    
    # if this is the first time the ball is not founnd
    if firstCall['BallNotFound']:
        memProxy.insertData('dntPhase', 'BallNotFound')
        memProxy.insertData('dntBallDist', 0)    
        ledProxy.fadeRGB('RightFaceLeds',0x00ff0000, 0) # no ball, led turns red
        mot.killWalk()
        firstCall['BallNotFound'] = False
        control = [0,0,0]
        
    # try to find a ball
    if vis.scanCircle(visThread, 0.2):
        phase = 'BallFound'
        firstCall['BallNotFound'] = True
    else:
        # if no ball is found circle slowly while searching for it
        mot.postWalkTo(0, 0, 1.3)