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()
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()
def omniPositionForKick(player): if player.firstFrame(): player.brain.tracker.trackBall() player.inKickingState = False # decide kick in util method # only enque once (for obstacle avoidance) player.brain.nav.goTo(getKickPosition(player), Navigator.CLOSE_ENOUGH, Navigator.FULL_SPEED, Navigator.ADAPTIVE) else: # update kicking position player.brain.nav.updateDest(getKickPosition(player)) # Did we lose the ball? if transitions.shouldFindBall(player): return player.goLater('gaurd') # At position? position = getKickPosition(player) if (0 < position.relX < constants.BALL_X_OFFSET and position.relY < constants.BALL_Y_OFFSET and position.relH < constants.GOOD_ENOUGH_H): print "kicking!" # KICK IT!!!$@%&!! player.brain.nav.stop() player.executeMove(SweetMoves.LEFT_BIG_KICK) #check this @! else: print "orbiting!" # ORBIT return player.stay()
def omniPositionForKick(player): if player.firstFrame(): player.brain.tracker.trackBall() player.inKickingState = False # decide kick in util method # only enque once (for obstacle avoidance) player.brain.nav.goTo(getKickPosition(player), Navigator.CLOSE_ENOUGH, Navigator.FULL_SPEED, Navigator.ADAPTIVE) else: # update kicking position player.brain.nav.updateDest(getKickPosition(player)) # Did we lose the ball? if transitions.shouldFindBall(player): return player.goLater('gaurd') # At position? position = getKickPosition(player) if (0 < position.relX < constants.BALL_X_OFFSET and position.relY < constants.BALL_Y_OFFSET and position.relH < constants.GOOD_ENOUGH_H): print "kicking!" # KICK IT!!!$@%&!! player.brain.nav.stop() player.executeMove(SweetMoves.LEFT_BIG_KICK) #check this @! else: print "orbiting!" # ORBIT return player.stay()
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()
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()
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.shouldFindBall(player) or transitions.shouldCancelOrbit(player)): player.inKickingState = False return player.goLater('chase') return player.stay()
def chase(player): """ Super State to determine what to do from various situations """ if transitions.shouldFindBall(player): return player.goNow('findBall') else: return player.goNow('spinToBall')
def chase(player): """ Super State to determine what to do from various situations """ if transitions.shouldFindBall(player): return player.goNow('findBall') else: return player.goNow('spinToBall')
def chase(player): """ Super State to determine what to do from various situations """ if transitions.shouldFindBall(player): return player.goNow("findBall") else: return player.goNow("approachBall")
def chase(player): """ Super State to determine what to do from various situations """ if transitions.shouldFindBall(player): return player.goNow('findBall') if player.brain.play.isRole(GOALIE) and goalTran.dangerousBall(player): return player.goNow('approachDangerousBall') else: return player.goNow('spinToBall')
def omniApproach(player): # If close to ball, switch to omniPosition if player.brain.ball.vis.dist < 50: return player.goLater('omniPositionForKick') # If lost the ball, stop and chill. if transitions.shouldFindBall(player): return player.goLater('gaurd') # Approach with all speed! player.brain.nav.chaseBall() return player.stay()
def omniApproach(player): # If close to ball, switch to omniPosition if player.brain.ball.distance < 50: return player.goLater('omniPositionForKick') # If lost the ball, stop and chill. if transitions.shouldFindBall(player): return player.goLater('gaurd') # Approach with all speed! player.brain.nav.chaseBall() return player.stay()
def chase(player): """ Super State to determine what to do from various situations """ if transitions.shouldFindBall(player): return player.goNow('findBall') if player.brain.play.isRole(GOALIE) and goalTran.dangerousBall(player): return player.goNow('approachDangerousBall') else: return player.goNow('positionForKick')
def orbitBall(player): """ State to orbit the ball """ if player.firstFrame(): player.brain.tracker.trackBall() player.brain.nav.orbitAngle(90) # TODO HACK HACK if transitions.shouldFindBall(player) or player.brain.nav.isStopped(): player.inKickingState = False player.shouldOrbit = False return player.goLater('lookAround') return player.stay()
def approachDangerousBall(player): """adjusts position to be farther away from the ball if the goalie is too close to the ball while in the goal box""" if player.firstFrame(): player.stopWalking() #move away from the ball so it is no longer dangerous if player.brain.nav.isStopped(): if player.brain.ball.loc.relY > 0: player.brain.nav.walk(0, -15, 0) else: player.brain.nav.walk(0, 15, 0) if not goalTran.dangerousBall(player) or transitions.shouldFindBall(player): return player.goLater('chase') return player.stay()
def approachDangerousBall(player): """adjusts position to be farther away from the ball if the goalie is too close to the ball while in the goal box""" if player.firstFrame(): player.stopWalking() #move away from the ball so it is no longer dangerous if player.brain.nav.isStopped(): if player.brain.ball.loc.relY > 0: player.brain.nav.walk(0, -15, 0) else: player.brain.nav.walk(0, 15, 0) if not goalTran.dangerousBall(player) or transitions.shouldFindBall(player): return player.goLater('chase') return player.stay()
def approachBall(player): if player.firstFrame(): player.brain.tracker.trackBall() player.brain.nav.chaseBall() # most of the time going to chase will kick back to here, lets us reset if transitions.shouldFindBall(player): return player.goLater('chase') if transitions.shouldPrepareForKick(player) or player.brain.nav.isAtPosition(): if player.shouldKickOff: player.kick = kicks.LEFT_SHORT_STRAIGHT_KICK player.shouldKickOff = False return player.goNow('positionForKick') else: return player.goNow('prepareForKick') else: return player.stay()
def spinToBall(player): if player.firstFrame(): player.brain.tracker.trackBallFixedPitch() player.brain.nav.stand() if transitions.shouldFindBall(player): return player.goLater('chase') if transitions.shouldStopSpinningToBall(player): return player.goNow('approachBall') else: spinDir = player.brain.my.spinDirToPoint(player.brain.ball.loc) if fabs(player.brain.ball.loc.bearing) > constants.CHANGE_SPEED_THRESH: speed = Navigator.GRADUAL_SPEED else: speed = Navigator.SLOW_SPEED player.setWalk(0,0,spinDir*speed) return player.stay()
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()
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()
def orbitBall(player): """ State to orbit the ball """ if player.firstFrame(): player.brain.tracker.performHeadMove(HeadMoves.KICK_SCAN) if player.brain.tracker.isStopped(): player.brain.tracker.trackBall() # Only orbit if we still don't have a kick player.brain.kickDecider.decideKick() if not transitions.shouldOrbit(player): return player.goLater('chase') player.brain.nav.orbitAngle(45) # TODO HACK HACK if transitions.shouldFindBall(player) or player.brain.nav.isStopped(): player.inKickingState = False player.shouldOrbit = False return player.goLater('chase') return player.stay()
def approachBall(player): if BoxTransitions.ballNotInBox(player): return player.goLater('positionAtHome') 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_SHORT_STRAIGHT_KICK else: player.kick = kicks.RIGHT_SHORT_STRAIGHT_KICK return player.goNow('positionForKick') else: return player.goNow('prepareForKick') else: return player.stay()