当前位置: 首页>>代码示例>>Python>>正文


Python ChaseBallTransitions类代码示例

本文整理汇总了Python中ChaseBallTransitions的典型用法代码示例。如果您正苦于以下问题:Python ChaseBallTransitions类的具体用法?Python ChaseBallTransitions怎么用?Python ChaseBallTransitions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ChaseBallTransitions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: approachBall

def approachBall(player):
    if player.brain.nav.dodging:
        return player.stay()

    if player.firstFrame():
        player.buffBoxFiltered = CountTransition(playOffTransitions.ballNotInBufferedBox,
                                                 0.8, 10)
        player.brain.tracker.trackBall()
        if player.shouldKickOff:
            if player.inKickOffPlay:
                return player.goNow('giveAndGo')
            else:
                return player.goNow('positionAndKickBall')

        elif player.penaltyKicking:
            return player.goNow('prepareForPenaltyKick')
        else:
            player.brain.nav.chaseBall(MAX_SPEED, fast = True)

    if (transitions.shouldPrepareForKick(player) or
        player.brain.nav.isAtPosition()):
        return player.goNow('positionAndKickBall')
    
    elif transitions.shouldDecelerate(player):
        player.brain.nav.chaseBall(MIN_SPEED, fast = True)
    else:
        player.brain.nav.chaseBall(MAX_SPEED, fast = True)
开发者ID:MarcusEFC,项目名称:nbites,代码行数:27,代码来源:ChaseBallStates.py

示例2: approachBall

def approachBall(player):
    if player.firstFrame():
        player.brain.tracker.trackBall()
        if player.shouldKickOff:
            player.brain.nav.chaseBall(Navigator.QUICK_SPEED)
        else:
            player.brain.nav.chaseBall()

    if (transitions.shouldFindBall(player) or
        transitions.shouldSpinToBall(player)):
        return player.goLater('chase')

    if (transitions.shouldPrepareForKick(player) or
        player.brain.nav.isAtPosition()):
        player.inKickingState = True
        if player.shouldKickOff:
            if player.brain.ball.rel_y > 0:
                player.kick = kicks.LEFT_SHORT_STRAIGHT_KICK
            else:
                player.kick = kicks.RIGHT_SHORT_STRAIGHT_KICK
            player.shouldKickOff = False
            return player.goNow('positionForKick')
        else:
            return player.goNow('prepareForKick')
    else:
        return player.stay()
开发者ID:dmcavoy,项目名称:nbites,代码行数:26,代码来源:ChaseBallStates.py

示例3: spinFindBall

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 go to a garbage state
    """

    if transitions.shouldApproachBall(player):
        return player.goNow('approachBall')

    if player.firstFrame():
        #if ball.on
        #player.brain.tracker.trackBallSpin()
        #else:
        #tracker.findBall()

        my = player.brain.my
        ball = player.brain.ball
        spinDir = my.spinDirToPoint(ball)

        player.setWalk(0, 0, spinDir*constants.FIND_BALL_SPIN_SPEED)

        player.brain.tracker.trackBallSpin()

    if not player.brain.play.isRole(GOALIE):
        if transitions.shouldWalkToBallLocPos(player):
            return player.goLater('approachBall')

    return player.stay()
开发者ID:AmeenaK,项目名称:nbites,代码行数:28,代码来源:FindBallStates.py

示例4: scanFindBall

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
    """
    if player.firstFrame():
        player.stopWalking()
        player.brain.tracker.trackBall()

    if transitions.shouldApproachBall(player):
        return player.goNow('approachBall')

    # 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.goNow('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()
开发者ID:AmeenaK,项目名称:nbites,代码行数:25,代码来源:FindBallStates.py

示例5: approachBall

def approachBall(player):
    if player.firstFrame():
        player.brain.tracker.trackBall()
        if player.shouldKickOff:
            player.brain.nav.chaseBall(Navigator.QUICK_SPEED, fast = True)
        else:
            player.brain.nav.chaseBall(fast = True)

    if (transitions.shouldFindBall(player)):
        print "DEBUG_SUIT: In 'approachBall', shouldFindBall is True. Switching to 'chase'."
        return player.goLater('chase')

    if (transitions.shouldPrepareForKick(player) or
        player.brain.nav.isAtPosition()):
        player.inKickingState = True

        if player.shouldKickOff:
            if player.brain.ball.rel_y > 0:
                player.kick = kicks.LEFT_STRAIGHT_KICK
            else:
                player.kick = kicks.RIGHT_STRAIGHT_KICK
            player.shouldKickOff = False
            return player.goNow('positionForKick')
        else:
            print "DEBUG_SUITE: In 'approachBall', either shouldPrepareForKick or nav.isAtPosition is True. Not a kickoff: switching to 'prepareForKick'."
            return player.goNow('prepareForKick')

    else:
        return player.stay()
开发者ID:oneamtu,项目名称:nbites,代码行数:29,代码来源:ChaseBallStates.py

示例6: positionForKick

def positionForKick(player):
    """
    Get the ball in the sweet spot
    """
    if transitions.shouldRedecideKick(player):
        return player.goLater('approachBall')

    ball = player.brain.ball
    positionForKick.kickPose = RelRobotLocation(ball.rel_x - player.kick.setupX,
                                                ball.rel_y - player.kick.setupY,
                                                0)

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

        if player.kick == kicks.M_LEFT_SIDE or player.kick == kicks.M_RIGHT_SIDE:
            positionForKick.speed = Navigator.GRADUAL_SPEED
        else:
            positionForKick.speed = MIN_SPEED

        player.brain.nav.destinationWalkTo(positionForKick.kickPose, 
                                            positionForKick.speed)

    elif player.brain.ball.vis.on: # don't update if we don't see the ball
        player.brain.nav.updateDestinationWalkDest(positionForKick.kickPose)

    player.ballBeforeKick = player.brain.ball
    if transitions.ballInPosition(player, positionForKick.kickPose):
        if player.motionKick:
           return player.goNow('executeMotionKick')
        else:
            player.brain.nav.stand()
            return player.goNow('executeKick')

    return player.stay()
开发者ID:MarcusEFC,项目名称:nbites,代码行数:35,代码来源:ChaseBallStates.py

示例7: positionPlaying

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()
开发者ID:bmende,项目名称:nbites,代码行数:27,代码来源:PositionStates.py

示例8: positionForKick

def positionForKick(player):
    """
    Get to the ball.
    Uses chaseBall to walk to the ball when its far away, and positionForKick
    once we get close. This allows Player to monitor Navigator's progress as it
    positions.
    """
    if player.penaltyKicking and player.brain.ball.loc.inOppGoalBox():
        return player.goNow('penaltyBallInOppGoalbox')

    if player.firstFrame():
        player.brain.tracker.trackBall()
        player.inKickingState = False

    if player.counter % 10 is 0:
        player.brain.kickDecider.decideKick()
        player.brain.nav.kickPosition(player.brain.kickDecider.getKick())

    # most of the time going to chase will kick back to here, lets us reset
    if transitions.shouldFindBallKick(player):
        player.inKickingState = False
        return player.goLater('chase')

    #if transitions.shouldKick(player):
    if transitions.ballInPosition(player) and (player.brain.nav.isStopped() or
                                               player.brain.nav.isAtPosition()):
        if transitions.shouldOrbit(player):
            return player.goNow('lookAround')
        else:
            return player.goNow('kickBallExecute')

    return player.stay()
开发者ID:Lrosias,项目名称:nbites,代码行数:32,代码来源:ChaseBallStates.py

示例9: spinFindBall

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()
开发者ID:chachi,项目名称:nbites,代码行数:26,代码来源:FindBallStates.py

示例10: approachBall

def approachBall(player):
    if player.firstFrame():
        player.brain.tracker.trackBall()
        if player.shouldKickOff:
            player.brain.nav.chaseBall(Navigator.QUICK_SPEED, fast = True)
        elif player.penaltyKicking:
            return player.goNow('prepareForPenaltyKick')
        else:
            player.brain.nav.chaseBall(fast = True)

    if transitions.shouldFindBall(player):
        return player.goLater('chase')

    if (transitions.shouldPrepareForKick(player) or
        player.brain.nav.isAtPosition()):

        if player.brain.nav.isAtPosition():
            print "isAtPosition() is causing the bug!"
        else:
            print "shouldPrepareForKick() is causing the bug!"
            print player.brain.ball.distance
            print player.brain.ball.vis.distance

        player.inKickingState = True
        if player.shouldKickOff:
            if player.brain.ball.rel_y > 0:
                player.kick = kicks.LEFT_STRAIGHT_KICK
            else:
                player.kick = kicks.RIGHT_STRAIGHT_KICK
            return player.goNow('positionForKick')
        else:
            return player.goNow('prepareForKick')
    else:
        return player.stay()
开发者ID:jzalinger,项目名称:nbites,代码行数:34,代码来源:ChaseBallStates.py

示例11: spinToBallClose

def spinToBallClose(player):
    """
    If the ball is really close to us, but we aren't facing it yet,
    stop and spin toward it, then decide your kick.
    """
    player.brain.tracker.trackBall()
    ball = player.brain.ball

    if (ball.relY > constants.SHOULD_STOP_Y or
        ball.relY < -1*constants.SHOULD_STOP_Y):
        spinDir = player.brain.my.spinDirToPoint(ball)
        player.setWalk(0, 0, spinDir*constants.BALL_SPIN_SPEED)
    else:
        if ball.dist > constants.SHOULD_START_DIST:
            player.brain.nav.chaseBall()
        else:
            player.stopWalking()
        return player.goNow('decideKick')
    if player.brain.tracker.activeLocOn:
        if transitions.shouldScanFindBallActiveLoc(player):
            return player.goLater('scanFindBall')
    elif transitions.shouldScanFindBall(player):
        return player.goLater('scanFindBall')

    return player.stay()
开发者ID:bbellon,项目名称:nbites,代码行数:25,代码来源:ChaseBallStates.py

示例12: waitBeforeKick

def waitBeforeKick(player):
    """
    Stop before we kick to make sure we want to kick
    """
    player.inKickingState = True
    if player.firstFrame():
        player.brain.CoA.setRobotGait(player.brain.motion)
        player.stopWalking()

    if not player.brain.nav.isStopped():
        return player.stay()

    if transitions.shouldKick(player):
        return player.goLater('getKickInfo')
    elif transitions.shouldApproachForKick(player):
        player.brain.tracker.trackBall()
        player.inKickingState = False
        return player.goLater('approachBall')
    elif transitions.shouldScanFindBall(player):
        player.inKickingState = False
        player.brain.tracker.trackBall()
        return player.goLater('scanFindBall')
    elif transitions.shouldRepositionForKick(player):
        player.brain.tracker.trackBall()
        return player.goLater('positionForKick')

    # Just don't get stuck here!
    if player.counter > 50:
        return player.goNow('scanFindBall')
    return player.stay()
开发者ID:iris-xx,项目名称:nao-man,代码行数:30,代码来源:ChaseBallStates.py

示例13: turnToBall

def turnToBall(player):
    """
    Rotate to align with the ball. When we get close, we will approach it
    """
    ball = player.brain.ball

    if player.firstFrame():
        player.hasAlignedOnce = False
        player.brain.tracker.trackBall()
        player.brain.CoA.setRobotGait(player.brain.motion)

    # Determine the speed to turn to the ball
    turnRate = MyMath.clip(ball.bearing*constants.BALL_SPIN_GAIN,
                           -constants.BALL_SPIN_SPEED,
                           constants.BALL_SPIN_SPEED)

    # Avoid spinning so slowly that we step in place
    if fabs(turnRate) < constants.MIN_BALL_SPIN_MAGNITUDE:
        turnRate = MyMath.sign(turnRate)*constants.MIN_BALL_SPIN_MAGNITUDE

    if ball.on:
        player.setSpeed(x=0,y=0,theta=turnRate)

    if transitions.shouldKick(player):
        return player.goNow('waitBeforeKick')
    elif transitions.shouldPositionForKick(player):
        return player.goNow('positionForKick')
    elif transitions.shouldApproachBall(player):
        return player.goLater('approachBall')
    elif transitions.shouldScanFindBall(player):
        return player.goLater('scanFindBall')

    return player.stay()
开发者ID:dmcavoy,项目名称:nao-man,代码行数:33,代码来源:ChaseBallStates.py

示例14: walkToWayPoint

def walkToWayPoint(player):
    if player.brain.nav.dodging:
        return player.stay()    

    if player.firstFrame():
        player.decider = KickDecider.KickDecider(player.brain)
        player.brain.tracker.trackBall()
    
    player.kick = player.decider.decidingStrategy()
    relH = player.decider.normalizeAngle(player.kick.setupH - player.brain.loc.h)

    ball = player.brain.ball

    if transitions.shouldDecelerate(player):
        speed = MIN_SPEED
    else:
        speed = MAX_SPEED

    if fabs(relH) <= constants.MAX_BEARING_DIFF:
        wayPoint = RobotLocation(ball.x - constants.WAYPOINT_DIST*cos(radians(player.kick.setupH)),
                                ball.y - constants.WAYPOINT_DIST*sin(radians(player.kick.setupH)),
                                player.brain.loc.h)

        player.brain.nav.goTo(wayPoint, Navigator.CLOSE_ENOUGH, speed, True, fast = True)

        if transitions.shouldSpinToKickHeading(player):
            return player.goNow('spinToKickHeading')

    else:
        player.brain.nav.chaseBall(speed, fast = True)

        if transitions.shouldPrepareForKick(player):
            return player.goLater('positionAndKickBall')

    return player.stay()
开发者ID:dnav6987,项目名称:nbites,代码行数:35,代码来源:ChaseBallStates.py

示例15: orbitBall

def orbitBall(player):
    """
    State to orbit the ball
    """
    if player.firstFrame():

        if hackKick.DEBUG_KICK_DECISION:
            print "Orbiting at angle: ",player.kick.h

        if player.kick.h == 0:
            return player.goNow('positionForKick')

        # Reset from pre-kick pan to straight, then track the ball.
        player.brain.tracker.lookStraightThenTrack()
        player.brain.nav.orbitAngle(player.orbitDistance, player.kick.h)

    elif player.brain.nav.isStopped():
        player.shouldOrbit = False
        player.kick.h = 0
        if player.kick == kicks.ORBIT_KICK_POSITION:
            return player.goNow('prepareForKick')
        else:
            player.kick = kicks.chooseAlignedKickFromKick(player, player.kick)
            return player.goNow('positionForKick')

    if (transitions.shouldFindBallKick(player) or
        transitions.shouldCancelOrbit(player)):
        player.inKickingState = False
        return player.goLater('chase')

    return player.stay()
开发者ID:dmcavoy,项目名称:nbites,代码行数:31,代码来源:ChaseBallStates.py


注:本文中的ChaseBallTransitions类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。