예제 #1
0
def positionForKick(player):
    """
    Get the ball in the sweet spot
    """
    if (transitions.shouldApproachBallAgain(player)
            or transitions.shouldRedecideKick(player)):
        player.inKickingState = False
        return player.goLater('chase')

    ball = player.brain.ball
    kick_pos = player.kick.getPosition()
    positionForKick.kickPose = RelRobotLocation(ball.rel_x - kick_pos[0],
                                                ball.rel_y - kick_pos[1], 0)

    #only enque the new goTo destination once
    if player.firstFrame():
        # Safer when coming from orbit in 1 frame. Still works otherwise, too.
        player.brain.tracker.lookStraightThenTrack()
        player.brain.nav.goTo(positionForKick.kickPose, Navigator.PRECISELY,
                              Navigator.GRADUAL_SPEED, False,
                              Navigator.ADAPTIVE)
    else:
        player.brain.nav.updateDest(positionForKick.kickPose)

    if transitions.shouldFindBallKick(player) and player.counter > 15:
        player.inKickingState = False
        return player.goLater('chase')

    if (transitions.ballInPosition(player, positionForKick.kickPose)
            or player.brain.nav.isAtPosition()):
        player.brain.nav.stand()
        return player.goNow('kickBallExecute')

    return player.stay()
예제 #2
0
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()
예제 #3
0
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()
예제 #4
0
def positionForPenaltyKick(player):
    """
    We're getting ready for a penalty kick
    """
    if player.firstFrame():
        positionForPenaltyKick.position = True
        player.inKickingState = True
        positionForPenaltyKick.yes = False
        if player.brain.ball.rel_y > 0:
            player.kick = kicks.LEFT_STRAIGHT_KICK
            print "Kicking with left"
        else:
            player.kick = kicks.RIGHT_STRAIGHT_KICK
            print "Kicking with right"

    if (transitions.shouldApproachBallAgain(player) or
        transitions.shouldRedecideKick(player)):
        player.inKickingState = False
        print "Going Back to Chase"
        return player.goLater('chase')

    ball = player.brain.ball
    kick_pos = player.kick.getPosition()
    positionForPenaltyKick.kickPose = RelRobotLocation(ball.rel_x - kick_pos[0],
                                                       ball.rel_y - kick_pos[1],
                                                       0)
    #So we stand and wait for two seconds before actually positioning
    if player.stateTime < 2:
        return player.stay()
    elif positionForPenaltyKick.position:
        player.ballBeforeApproach = player.brain.ball
        player.brain.tracker.lookStraightThenTrack()
        positionForPenaltyKick.position = True
        player.brain.nav.goTo(positionForPenaltyKick.kickPose,
                              Navigator.PRECISELY,
                              Navigator.CAREFUL_SPEED,
                              False,
                              Navigator.ADAPTIVE)
        positionForPenaltyKick.position = False
    else:
        player.brain.nav.updateDest(positionForPenaltyKick.kickPose)

    if (transitions.ballInPosition(player, positionForPenaltyKick.kickPose) or
        player.brain.nav.isAtPosition()):
        positionForPenaltyKick.yes = True
        #return player.stay()
        player.brain.nav.stand()
        return player.goNow('kickBallExecute')

    if positionForPenaltyKick.yes:
        print "ball relX: ", ball.rel_x
        print "ball relY: ", ball.rel_y

    return player.stay()
예제 #5
0
def positionForPenaltyKick(player):
    """
    We're getting ready for a penalty kick
    """
    if player.firstFrame():
        positionForPenaltyKick.position = True
        player.inKickingState = True
        positionForPenaltyKick.yes = False
        if player.brain.ball.rel_y > 0:
            player.kick = kicks.LEFT_STRAIGHT_KICK
            print "Kicking with left"
        else:
            player.kick = kicks.RIGHT_STRAIGHT_KICK
            print "Kicking with right"

    if (transitions.shouldApproachBallAgain(player)
            or transitions.shouldRedecideKick(player)):
        player.inKickingState = False
        print "Going Back to Chase"
        return player.goLater('chase')

    ball = player.brain.ball
    kick_pos = player.kick.getPosition()
    positionForPenaltyKick.kickPose = RelRobotLocation(
        ball.rel_x - kick_pos[0], ball.rel_y - kick_pos[1], 0)
    #So we stand and wait for two seconds before actually positioning
    if player.stateTime < 2:
        return player.stay()
    elif positionForPenaltyKick.position:
        player.ballBeforeApproach = player.brain.ball
        player.brain.tracker.lookStraightThenTrack()
        positionForPenaltyKick.position = True
        player.brain.nav.goTo(positionForPenaltyKick.kickPose,
                              Navigator.PRECISELY, Navigator.CAREFUL_SPEED,
                              False, Navigator.ADAPTIVE)
        positionForPenaltyKick.position = False
    else:
        player.brain.nav.updateDest(positionForPenaltyKick.kickPose)

    if (transitions.ballInPosition(player, positionForPenaltyKick.kickPose)
            or player.brain.nav.isAtPosition()):
        positionForPenaltyKick.yes = True
        #return player.stay()
        player.brain.nav.stand()
        return player.goNow('kickBallExecute')

    if positionForPenaltyKick.yes:
        print "ball relX: ", ball.rel_x
        print "ball relY: ", ball.rel_y

    return player.stay()
예제 #6
0
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()
        player.brain.nav.destinationWalkTo(positionForKick.kickPose,
                                           Navigator.MEDIUM_SPEED)
        positionForKick.slowDown = False
    elif player.brain.ball.vis.on:  # don't update if we don't see the ball
        # slows down the walk when very close to the ball to stabalize motion kicking and to not walk over the ball
        if player.kick == kicks.M_LEFT_STRAIGHT or player.kick == kicks.M_RIGHT_STRAIGHT:
            if (not positionForKick.slowDown and player.brain.ball.distance <
                    constants.SLOW_DOWN_TO_BALL_DIST):
                positionForKick.slowDown = True
                player.brain.nav.destinationWalkTo(positionForKick.kickPose,
                                                   Navigator.GRADUAL_SPEED)
            elif (positionForKick.slowDown and player.brain.ball.distance >=
                  constants.SLOW_DOWN_TO_BALL_DIST):
                positionForKick.slowDown = False
                player.brain.nav.destinationWalkTo(positionForKick.kickPose,
                                                   Navigator.MEDIUM_SPEED)
            else:
                player.brain.nav.updateDestinationWalkDest(
                    positionForKick.kickPose)
        else:
            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()
예제 #7
0
def positionForKick(player):
    """
    Get the ball in the sweet spot
    """
    if (transitions.shouldApproachBallAgain(player) or
        transitions.shouldRedecideKick(player)):
        player.inKickingState = False
        return player.goLater('chase')

    if not player.shouldKickOff or DRIBBLE_ON_KICKOFF:
        if dr_trans.shouldDribble(player):
            return player.goNow('decideDribble')

    if player.corner_dribble:
        return player.goNow('executeDribble')

    ball = player.brain.ball
    kick_pos = player.kick.getPosition()
    positionForKick.kickPose = RelRobotLocation(ball.stat_rel_x - kick_pos[0],
                                                ball.stat_rel_y - kick_pos[1],
                                                0)

    if player.firstFrame():
        # Safer when coming from orbit in 1 frame. Still works otherwise, too.
        player.brain.tracker.lookStraightThenTrack()
        #only enque the new goTo destination once and update it afterwards
        player.brain.nav.goTo(positionForKick.kickPose,
                              Navigator.PRECISELY,
                              Navigator.SLOW_SPEED,
                              False,
                              Navigator.ADAPTIVE)
    else:
        player.brain.nav.updateDest(positionForKick.kickPose)

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

    if (transitions.ballInPosition(player, positionForKick.kickPose) or
        player.brain.nav.isAtPosition()):
        player.ballBeforeKick = player.brain.ball
        player.brain.nav.stand()
        return player.goNow('kickBallExecute')

    return player.stay()
예제 #8
0
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()
        player.brain.nav.destinationWalkTo(positionForKick.kickPose,
                                           Navigator.BRISK_SPEED)
        positionForKick.slowDown = False
    elif player.brain.ball.vis.on: # don't update if we don't see the ball
        # slows down the walk when very close to the ball to stabalize motion kicking and to not walk over the ball
        if player.motionKick:
            if (not positionForKick.slowDown and 
                player.brain.ball.distance < constants.SLOW_DOWN_TO_BALL_DIST):
                positionForKick.slowDown = True
                player.brain.nav.destinationWalkTo(positionForKick.kickPose,
                                           Navigator.SLOW_SPEED)
            elif (positionForKick.slowDown and 
                player.brain.ball.distance >= constants.SLOW_DOWN_TO_BALL_DIST):
                positionForKick.slowDown = False
                player.brain.nav.destinationWalkTo(positionForKick.kickPose,
                                           Navigator.BRISK_SPEED)
            else:
                player.brain.nav.updateDestinationWalkDest(positionForKick.kickPose)
        else:
            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()
예제 #9
0
def positionForKick(player):
    """
    Get the ball in the sweet spot
    """
    if (transitions.shouldApproachBallAgain(player) or
        transitions.shouldRedecideKick(player)):
        player.inKickingState = False
        return player.goLater('chase')

    if not player.shouldKickOff or DRIBBLE_ON_KICKOFF:
        if dr_trans.shouldDribble(player):
            return player.goNow('decideDribble')

    if player.corner_dribble:
        return player.goNow('executeDribble')

    ball = player.brain.ball
    kick_pos = player.kick.getPosition()
    positionForKick.kickPose = RelRobotLocation(ball.rel_x - kick_pos[0],
                                                ball.rel_y - kick_pos[1],
                                                0)

    if player.firstFrame():
        player.brain.tracker.lookStraightThenTrack()
        player.brain.nav.destinationWalkTo(positionForKick.kickPose,
                                           Navigator.SLOW_SPEED,
                                           True)
    elif player.brain.ball.vis.on: # don't update if we don't see the ball
        player.brain.nav.updateDestinationWalkDest(positionForKick.kickPose)

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

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

    return player.stay()
예제 #10
0
def positionForKick(player):
    """
    Get the ball in the sweet spot
    """
    if (transitions.shouldApproachBallAgain(player) or
        transitions.shouldRedecideKick(player)):
        print "DEBUG_SUITE: In 'positionForKick', either shouldApproachBallAgain or shouldRedecideKick. Switching to 'chase'."
        player.inKickingState = False
        return player.goLater('chase')

    ball = player.brain.ball
    kick_pos = player.kick.getPosition()
    positionForKick.kickPose = RelRobotLocation(ball.rel_x - kick_pos[0],
                                                ball.rel_y - kick_pos[1],
                                                0)

    #only enque the new goTo destination once
    if player.firstFrame():
        # Safer when coming from orbit in 1 frame. Still works otherwise, too.
        player.brain.tracker.lookStraightThenTrack()
        #TODO: try getting rid of ADAPTIVE here, if ball estimates are good,
        #we don't need to lower the speed/shuffle to the ball
        player.brain.nav.goTo(positionForKick.kickPose,
                              Navigator.PRECISELY,
                              Navigator.GRADUAL_SPEED,
                              False,
                              Navigator.ADAPTIVE)
    else:
        player.brain.nav.updateDest(positionForKick.kickPose)

    if transitions.shouldFindBallKick(player) and player.counter > 15:
        print "DEBUG_SUITE: In 'positionForKick', both shouldFindBallKick and counter >15. Switching to 'chase'."
        player.inKickingState = False
        return player.goLater('chase')

    if (transitions.ballInPosition(player, positionForKick.kickPose) or
        player.brain.nav.isAtPosition()):
        print "DEBUG_SUITE: In 'positionForKick', either ballInPosition or nav.isAtPosition. Switching to 'kickBallExecute'."
        player.brain.nav.stand()
        return player.goNow('kickBallExecute')

    return player.stay()
예제 #11
0
def positionForKick(player):
    """
    Get the ball in the sweet spot
    """
    if (transitions.shouldApproachBallAgain(player)
            or transitions.shouldRedecideKick(player)):
        player.inKickingState = False
        return player.goLater('chase')

    if not player.shouldKickOff or DRIBBLE_ON_KICKOFF:
        if dr_trans.shouldDribble(player):
            return player.goNow('decideDribble')

    if player.corner_dribble:
        return player.goNow('executeDribble')

    ball = player.brain.ball
    kick_pos = player.kick.getPosition()
    positionForKick.kickPose = RelRobotLocation(ball.rel_x - kick_pos[0],
                                                ball.rel_y - kick_pos[1], 0)

    if player.firstFrame():
        player.brain.tracker.lookStraightThenTrack()
        player.brain.nav.destinationWalkTo(positionForKick.kickPose,
                                           Navigator.SLOW_SPEED, True)
    elif player.brain.ball.vis.on:  # don't update if we don't see the ball
        player.brain.nav.updateDestinationWalkDest(positionForKick.kickPose)

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

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

    return player.stay()
예제 #12
0
def positionForKick(player):
    """
    Get the ball in the sweet spot
    """
    if (transitions.shouldApproachBallAgain(player) or
        transitions.shouldRedecideKick(player)):
        player.inKickingState = False
        return player.goLater('chase')

    ball = player.brain.ball
    kick_pos = player.kick.getPosition()
    positionForKick.kickPose = RelRobotLocation(ball.rel_x - kick_pos[0],
                                                ball.rel_y - kick_pos[1],
                                                0)

    #only enque the new goTo destination once
    if player.firstFrame():
        # Safer when coming from orbit in 1 frame. Still works otherwise, too.
        player.brain.tracker.lookStraightThenTrack()
        player.brain.nav.goTo(positionForKick.kickPose,
                              Navigator.PRECISELY,
                              Navigator.GRADUAL_SPEED,
                              False,
                              Navigator.ADAPTIVE)
    else:
        player.brain.nav.updateDest(positionForKick.kickPose)

    if transitions.shouldFindBallKick(player) and player.counter > 15:
        player.inKickingState = False
        return player.goLater('chase')

    if (transitions.ballInPosition(player, positionForKick.kickPose) or
        player.brain.nav.isAtPosition()):
        player.brain.nav.stand()
        return player.goNow('kickBallExecute')

    return player.stay()
예제 #13
0
def positionForKick(player):
    """
    Get the ball in the sweet spot
    """
    if transitions.shouldRedecideKick(player):
        print("I think I should redecide my kick!!")
        return player.goLater('approachBall')

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

    # print("")
    # print("Ball is: ", ball.rel_x, ball.rel_y)
    # print("Ball dist:", ball.distance)
    # print("My kick setup is: ", player.kick.setupX, player.kick.setupY)

    # print("Ball.rel_x:", ball.rel_x, "rel_y:", ball.rel_y)

    if player.firstFrame():
        # print("IN position for kick, should kick off: ", player.shouldKickOff)
        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 = speeds.SPEED_TWO
        # print("In position for kick! Setting walk speed")
        # print("My location:", str(positionForKick.kickPose))
        player.brain.nav.goTo(positionForKick.kickPose,
                              Navigator.CLOSE_ENOUGH,
                              speeds.SPEED_FIVE,
                              True,
                              fast=True,
                              useLoc=False)
        # player.brain.nav.walkTo(positionForKick.kickPose, speeds.SPEED_THREE)

        # player.setWalk()

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

    elif player.brain.ball.vis.on:  # don't update if we don't see the ball
        # print "positionForKick -- we don't see it"
        player.brain.nav.updateDest(positionForKick.kickPose)
        # print("MY kickpose:", str(positionForKick.kickPose))
        # player.brain.nav.updateDestinationWalkDest(positionForKick.kickPose)

    # print "positionForKick"

    # print "positionForKick"

    player.ballBeforeKick = player.brain.ball
    # print("Kickpose: ", str(positionForKick.kickPose))

    if (transitions.ballInPosition(player, positionForKick.kickPose)
            or player.brain.nav.currentState is 'atPosition'):
        # print("The ball is in position! CHASEBALL")
        # print player.kick
        player.shouldKickOff = False
        return player.goLater('executeSweetKick')
        # if player.motionKick or True:
        #    return player.goNow('executeMotionKick')
        # elif player.kick.bhKickType or True:
        #     player.brain.nav.stand()
        #     return player.goLater('executeBHKick')
        # else:
        #     player.brain.nav.stand()
        #     return player.goLater('executeSweetKick')

    return player.stay()
예제 #14
0
def positionForKick(player):
    """
    Get the ball in the sweet spot
    """
    if transitions.shouldRedecideKick(player):
        print("I think I should redecide my kick!!")
        return player.goLater('approachBall')

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

    # print("")
    # print("Ball is: ", ball.rel_x, ball.rel_y)
    # print("Ball dist:", ball.distance)
    # print("My kick setup is: ", player.kick.setupX, player.kick.setupY)

    # print("Ball.rel_x:", ball.rel_x, "rel_y:", ball.rel_y)

    if player.firstFrame():
        # print("IN position for kick, should kick off: ", player.shouldKickOff)
        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 = speeds.SPEED_TWO
        # print("In position for kick! Setting walk speed")
        # print("My location:", str(positionForKick.kickPose))
        player.brain.nav.goTo(positionForKick.kickPose, Navigator.CLOSE_ENOUGH,
                              speeds.SPEED_FIVE, True, fast = True, useLoc = False)
        # player.brain.nav.walkTo(positionForKick.kickPose, speeds.SPEED_THREE)

        # player.setWalk()

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

    elif player.brain.ball.vis.on: # don't update if we don't see the ball
        # print "positionForKick -- we don't see it"
        player.brain.nav.updateDest(positionForKick.kickPose)
        # print("MY kickpose:", str(positionForKick.kickPose))
        # player.brain.nav.updateDestinationWalkDest(positionForKick.kickPose)

    # print "positionForKick"

    # print "positionForKick"

    player.ballBeforeKick = player.brain.ball
    # print("Kickpose: ", str(positionForKick.kickPose))

    if (transitions.ballInPosition(player, positionForKick.kickPose)
    or player.brain.nav.currentState is 'atPosition'):
        # print("The ball is in position! CHASEBALL")
        # print player.kick
        player.shouldKickOff = False
        return player.goLater('executeSweetKick')
        # if player.motionKick or True:
        #    return player.goNow('executeMotionKick')
        # elif player.kick.bhKickType or True:
        #     player.brain.nav.stand()
        #     return player.goLater('executeBHKick')
        # else:
        #     player.brain.nav.stand()
        #     return player.goLater('executeSweetKick')

    return player.stay()