コード例 #1
0
ファイル: FindBallStates.py プロジェクト: jzalinger/nbites
def spinFindBall(player):
    """
    State to spin to find the ball. If we find the ball, we
    move to align on it. If we don't find it, we walk to look for it
    """
    if transitions.shouldChaseBall(player):
        player.stopWalking()
        player.brain.tracker.trackBall()
        return player.goLater('findBall')

    if player.firstFrame():
        player.brain.tracker.stopHeadMoves()
        player.stopWalking()

    if player.brain.nav.isStopped() and player.brain.tracker.isStopped():
        my = player.brain.loc
        ball = Location(player.brain.ball.x, player.brain.ball.y)
        spinDir = my.spinDirToPoint(ball)
        player.setWalk(0, 0, spinDir*constants.FIND_BALL_SPIN_SPEED)

        player.brain.tracker.spinPan()

    if ((player.brain.play.isChaser() and transitions.shouldWalkFindBall(player))
        or (not player.brain.play.isChaser() and transitions.spunOnce(player))):
        return player.goLater('playbookPosition')

    return player.stay()
コード例 #2
0
ファイル: PositionStates.py プロジェクト: bmende/nbites
def positionPlaying(player):
    """
    Game Playing positioning
    """
    if player.firstFrame():
        player.brain.nav.positionPlaybook()
        player.brain.tracker.repeatBasicPan() # TODO Landmarks

    if player.brain.ball.vis.on and player.brain.ball.distance < 100:
        player.brain.tracker.trackBall()
    else:
        player.brain.tracker.repeatBasicPan() # TODO Landmarks

    if player.brain.nav.isAtPosition():
        player.brain.tracker.trackBall()

    if player.brain.play.isChaser() and transitions.shouldChaseBall(player):
        return player.goLater('chase')

    if transitions.shouldFindBallPosition(player):
        return player.goLater('findBall')

    if player.brain.locUncert > 75:
        # Find some goalposts (preferably close ones) and walk toward them.
        pass

    return player.stay()
コード例 #3
0
ファイル: FindBallStates.py プロジェクト: chachi/nbites
def spinFindBall(player):
    """
    State to spin to find the ball. If we find the ball, we
    move to align on it. If we don't find it, we walk to look for it
    """
    if transitions.shouldChaseBall(player):
        player.stopWalking()
        player.brain.tracker.trackBall()
        return player.goNow('findBall')

    if player.firstFrame():
        player.brain.tracker.stopHeadMoves()

    if player.brain.nav.isStopped() and player.brain.tracker.isStopped():
        my = player.brain.my
        ball = player.brain.ball
        spinDir = my.spinDirToPoint(ball.loc)
        player.setWalk(0, 0, spinDir*constants.FIND_BALL_SPIN_SPEED)

        player.brain.tracker.trackBallSpin()

    if not player.brain.play.isRole(GOALIE):
        if transitions.shouldWalkFindBall(player):
            return player.goLater('walkFindBall')

    return player.stay()
コード例 #4
0
def spinFindBall(player):
    """
    State to spin to find the ball. If we find the ball, we
    move to align on it. If we don't find it, we walk to look for it
    """
    if transitions.shouldChaseBall(player):
        player.stopWalking()
        player.brain.tracker.trackBall()
        return player.goNow('findBall')

    if player.firstFrame():
        player.brain.tracker.stopHeadMoves()

    if player.brain.nav.isStopped() and player.brain.tracker.isStopped():
        my = player.brain.loc
        ball = Location(player.brain.ball.x, player.brain.ball.y)
        spinDir = my.spinDirToPoint(ball)
        player.setWalk(0, 0, spinDir * constants.FIND_BALL_SPIN_SPEED)

        player.brain.tracker.spinPan()

    if transitions.shouldWalkFindBall(player):
        return player.goLater('walkFindBall')

    return player.stay()
コード例 #5
0
ファイル: FindBallStates.py プロジェクト: jzalinger/nbites
def findBall(player):
    """
    State to stop all activity and begin finding the ball
    """
    if transitions.shouldChaseBall(player):
        if not player.brain.play.isChaser():
            return player.goLater('playbookPosition')
        else:
            return player.goLater('chase')

    return player.goNow('spinFindBall')
コード例 #6
0
ファイル: FindBallStates.py プロジェクト: gnmerritt/nbites
def findBall(player):
    """
    State to stop all activity and begin finding the ball
    """
    if transitions.shouldChaseBall(player):
        return player.goLater('chase')

    if player.firstFrame():
        player.stopWalking()
        player.brain.tracker.stopHeadMoves()

    if player.brain.nav.isStopped():
        return player.goLater('scanFindBall')

    return player.stay()
コード例 #7
0
def scanFindBall(player):
    """
    State to move the head to find the ball. If we find the ball, we
    mppove to align on it. If we don't find it, we spin to keep looking
    """
    player.brain.tracker.trackBall()

    if transitions.shouldChaseBall(player):
        return player.goNow('findBall')

    # a time based check.
    if transitions.shouldSpinFindBall(player):
        return player.goLater('spinFindBall')

    return player.stay()
コード例 #8
0
ファイル: FindBallStates.py プロジェクト: dmcavoy/nbites
def scanFindBall(player):
    """
    State to move the head to find the ball. If we find the ball, we
    mppove to align on it. If we don't find it, we spin to keep looking
    """
    player.brain.tracker.trackBall()

    if transitions.shouldChaseBall(player):
        return player.goNow('findBall')

    # a time based check.
    if transitions.shouldSpinFindBall(player):
        return player.goLater('spinFindBall')

    return player.stay()
コード例 #9
0
ファイル: PenaltyKickStates.py プロジェクト: bbellon/nbites
def penaltyKickShortDribble(player):
    """
    Acts as a layer above dribble for penalty shots.
    """
    if player.firstFrame():
        player.penaltyMadeFirstKick = True
    if transitions.shouldStopPenaltyKickDribbling(player):

        if transitions.shouldStopBeforeKick(player):
            return player.goLater("chase")
        elif transitions.shouldPositionForKick(player):
            return player.goLater("positionForKick")
        elif transitions.shouldChaseBall(player):
            return player.goLater("chase")

    return player.goLater("dribble")
コード例 #10
0
ファイル: FindBallStates.py プロジェクト: chachi/nbites
def scanFindBall(player):
    """
    State to move the head to find the ball. If we find the ball, we
    mppove to align on it. If we don't find it, we spin to keep looking
    """
    player.brain.tracker.trackBall()

    if transitions.shouldChaseBall(player):
        return player.goNow('findBall')

    # a time based check. may be a problem for goalie. if it's not
    # good for him to spin, he should prbly not be chaser anymore, so
    # this wouldn't get reached
    if transitions.shouldSpinFindBall(player):
        return player.goLater('spinFindBall')

    return player.stay()
コード例 #11
0
def scanFindBall(player):
    """
    State to move the head to find the ball. If we find the ball, we
    mppove to align on it. If we don't find it, we spin to keep looking
    """
    player.brain.tracker.trackBallFixedPitch()

    if transitions.shouldChaseBall(player):
        return player.goNow('findBall')

    # a time based check. may be a problem for goalie. if it's not
    # good for him to spin, he should prbly not be chaser anymore, so
    # this wouldn't get reached
    if transitions.shouldSpinFindBall(player):
        return player.goLater('spinFindBall')

    return player.stay()
コード例 #12
0
ファイル: FindBallStates.py プロジェクト: alawrenc/nbites
def walkFindBall(player):
    """
    State to walk to find the ball. If we find the ball we chase it.
    """
    if transitions.shouldChaseBall(player):
        player.stopWalking()
        player.brain.tracker.trackBall()
        return player.goNow('chase')

    if player.brain.nav.isStopped():
        player.brain.nav.chaseBall()

    player.brain.tracker.trackBall()

    if transitions.shouldSpinFindBallAgain(player):
        return player.goLater('spinFindBall')

    return player.stay()
コード例 #13
0
def findBall(player):
    """
    State to stop all activity and begin finding the ball
    """
    if transitions.shouldChaseBall(player):
        if not player.brain.play.isChaser():
            return player.goLater('playbookPosition')
        else:
            return player.goLater('chase')

    if player.firstFrame():
        player.stand()
        player.brain.tracker.stopHeadMoves()

    if player.brain.nav.isStopped():
        return player.goLater('scanFindBall')

    return player.stay()
コード例 #14
0
ファイル: PenaltyStates.py プロジェクト: dmcavoy/nbites
def afterPenalty(player):

    if player.firstFrame():
        # pan for the ball
        player.brain.tracker.repeatWidePan()
        # walk towards your own field cross
        player.brain.nav.walkTo(RelRobotLocation(200,0,0))

    if transitions.shouldChaseBall(player):
        if not player.brain.play.isChaser():
            return player.goLater('playbookPosition')
        else:
            return player.goLater('chase')

    # TODO: Make this work for two yellow goals & resetLoc to one place?
    # Would be great if loc worked. Hacked out for US OPEN 2012
    """
    if not player.brain.motion.head_is_active:
        ##looking to the side
        if player.brain.yglp.on or player.brain.ygrp.on:
            #see the goal posts in multiple frames for safety
            seeYellow(player)
            if player.yellowCount >= OBJ_SEEN_THRESH:
                setLocInfo(player)
                #now you know where you are!
                return player.goLater(gcState)

        if player.brain.bglp.vis.on or player.brain.bgrp.vis.on:
            #see the goal posts in multiple frames for safety
            seeBlue(player)
            if player.blueCount >= OBJ_SEEN_THRESH:
                setLocInfo(player)
                #now you know where you are!
                return player.goLater(gcState)
        player.headCount += 1
    """

    # If done walking forward, start relocalizing normally
    if player.brain.nav.isStopped() or player.counter > 250:
        player.brain.nav.stop()
        return player.goLater('findBall')

    return player.stay()
コード例 #15
0
ファイル: PenaltyStates.py プロジェクト: thiggins/nbites
def afterPenalty(player):

    if player.firstFrame():
        # pan for the ball
        player.brain.tracker.repeatWidePanFixedPitch()
        # walk towards your own field cross
        player.brain.nav.walkTo(RelRobotLocation(200, 0, 0))

    if transitions.shouldChaseBall(player):
        if not player.brain.play.isChaser():
            return player.goLater('playbookPosition')
        else:
            return player.goLater('chase')

    # Would be great if loc worked. Hacked out for US OPEN 2012
    """
    if not player.brain.motion.isHeadActive():
        ##looking to the side
        if player.brain.yglp.vis.on or player.brain.ygrp.vis.on:
            #see the goal posts in multiple frames for safety
            seeYellow(player)
            if player.yellowCount >= OBJ_SEEN_THRESH:
                setLocInfo(player)
                #now you know where you are!
                return player.goLater(gcState)

        if player.brain.bglp.vis.on or player.brain.bgrp.vis.on:
            #see the goal posts in multiple frames for safety
            seeBlue(player)
            if player.blueCount >= OBJ_SEEN_THRESH:
                setLocInfo(player)
                #now you know where you are!
                return player.goLater(gcState)
        player.headCount += 1
    """

    # If done walking forward, start relocalizing normally
    if player.brain.nav.isStopped() or player.counter > 250:
        player.brain.nav.stop()
        return player.goLater('findBall')

    return player.stay()
コード例 #16
0
ファイル: PenaltyStates.py プロジェクト: jzalinger/nbites
def postPenaltyChaser(player):
    """
    If we come out of penalty directly into chaser, we'll waste
    time spinning on the side of the field. Instead, if we didn't
    see the ball during afterPenalty, odometry walk onto the field
    before spinning.
    """
    if player.firstFrame():
        player.brain.nav.walkTo(RelRobotLocation(200,0,0))
        player.brain.tracker.trackBall()
    elif (player.brain.nav.isStopped() or
          transitions.shouldChaseBall(player)):
        return player.goLater('chase')

    if not player.brain.play.isChaser():
        # We've role switched out naturally. Go to appropriate state.
        player.stopWalking() # walkTo is a bit dangerous. do this to be careful.
        return player.goLater('playbookPosition')

    return player.stay()
コード例 #17
0
ファイル: ChaseBallStates.py プロジェクト: bbellon/nbites
def dribble(player):
    """
    Keep running at the ball, but dribble
    """
    if player.firstFrame():
        player.brain.nav.dribble()

    if transitions.shouldScanFindBallKick(player):
        return player.goLater('scanFindBall')
    # if we should stop dribbling, see what else we should do
    if transitions.shouldStopDribbling(player):
        # may not be appropriate due to turned out feet...
        if transitions.shouldStopBeforeKick(player):
            return player.goLater('stopBeforeKick')
        if transitions.shouldPositionForKick(player):
            return player.goLater('decideKick')
        elif transitions.shouldChaseBall(player):
            return player.goLater('chase')

    return player.stay()
コード例 #18
0
ファイル: PositionStates.py プロジェクト: jzalinger/nbites
def positionPlaying(player):
    """
    Game Playing positioning
    """
    if player.firstFrame():
        player.brain.nav.positionPlaybook()
        player.brain.tracker.trackBall()

    if player.brain.play.isChaser() and transitions.shouldChaseBall(player):
        return player.goLater('chase')

    if transitions.shouldFindBallPosition(player):
        #return player.goLater('findBall')
        pass

    if player.brain.locUncert > 75:
        # Find some goalposts (preferably close ones) and walk toward them.
        pass

    return player.stay()
コード例 #19
0
ファイル: PositionStates.py プロジェクト: suthumb/nbites
def positionPlaying(player):
    """
    Game Playing positioning
    """
    if player.firstFrame():
        player.brain.tracker.trackBall()
        if player.usingBoxPositions:
            return player.goLater('positionAtHome')

    if player.brain.play.isChaser() and transitions.shouldChaseBall(player):
        return player.goLater('chase')

    if transitions.shouldFindBallPosition(player):
        #return player.goLater('findBall')
        pass

    if player.brain.locUncert > 75:
        # Find some goalposts (preferably close ones) and walk toward them.
        pass

    return player.stay()
コード例 #20
0
def walkFindBall(player):
    """
    State to walk to find the ball. If we find the ball we chase it.
    """
    if player.firstFrame():
        player.stopWalking()
        # Do a slow pan
        player.brain.tracker.repeatWidePan()

    if transitions.shouldChaseBall(player):
        player.stopWalking()
        player.brain.tracker.trackBall()
        return player.goNow('findBall')

    if player.brain.nav.isStopped():
        player.brain.nav.chaseBall()

    if transitions.shouldSpinFindBallAgain(player):
        return player.goLater('spinFindBall')

    return player.stay()
コード例 #21
0
ファイル: FindBallStates.py プロジェクト: WangHanbin/nbites
def walkFindBall(player):
    """
    State to walk to find the ball. If we find the ball we chase it.
    """
    if player.firstFrame():
        player.stopWalking()
        # Do a slow pan
        player.brain.tracker.repeatWidePanFixedPitch()

    if transitions.shouldChaseBall(player):
        player.stopWalking()
        player.brain.tracker.trackBallFixedPitch()
        return player.goNow('findBall')

    if player.brain.nav.isStopped():
        player.brain.nav.chaseBall()

    if transitions.shouldSpinFindBallAgain(player):
        return player.goLater('spinFindBall')

    return player.stay()
コード例 #22
0
def postPenaltyChaser(player):
    """
    If we come out of penalty directly into chaser, we'll waste
    time spinning on the side of the field. Instead, if we didn't
    see the ball during afterPenalty, odometry walk onto the field
    before spinning.
    """
    if player.firstFrame():
        player.brain.nav.walkTo(RelRobotLocation(200,0,0))
        player.brain.tracker.trackBall()
    elif (player.brain.nav.isStopped() or
          transitions.shouldChaseBall(player)):
        return player.goLater('chase')

    if not player.brain.play.isChaser():
        # We've role switched out naturally. Go to appropriate state.
        player.stopWalking() # walkTo is a bit dangerous. do this to be careful.
        if player.usingBoxPositions:
            return player.goLater('positionAtHome')
        return player.goLater('playbookPosition')

    return player.stay()
コード例 #23
0
ファイル: FindBallStates.py プロジェクト: alawrenc/nbites
def scanFindBall(player):
    """
    State to move the head to find the ball. If we find the ball, we
    move to align on it. If we don't find it, we spin to keep looking
    """
    player.stopWalking()
    player.brain.tracker.trackBall()

    if transitions.shouldChaseBall(player):
        return player.goNow('chase')

    # a time based check. may be a problem for goalie. if it's not good for him to
    # spin, he should prbly not be chaser anymore, so this wouldn't get reached
    if transitions.shouldSpinFindBall(player):
        return player.goLater('spinFindBall')

#    ball = player.brain.ball
#    if fabs(ball.bearing) < constants.SCAN_FIND_BEARING_THRESH:
#        return player.stay()
#
#    else:
#        return player.goLater('spinFindBall')

    return player.stay()