def positionAtHome(player): """ Go to the player's home position. Defenders look in the direction of the shared ball if it is on with reliability >= 2. Cherry pickers look in the direction of the shared ball if it is on with reliability >= 1. """ if player.firstFrame(): player.brain.tracker.trackBall() home = RobotLocation(player.homePosition.x, player.homePosition.y, player.homePosition.h) if (player.brain.sharedBall.ball_on and player.brain.sharedBall.reliability >= 2 and role.isDefender(player.role)): sharedball = Location(player.brain.sharedBall.x, player.brain.sharedBall.y) home.h = player.brain.loc.getRelativeBearing(sharedball) elif (player.brain.sharedBall.ball_on and player.brain.sharedBall.reliability >= 1 and role.isCherryPicker(player.role)): sharedball = Location(player.brain.sharedBall.x, player.brain.sharedBall.y) home.h = player.brain.loc.getRelativeBearing(sharedball) fastWalk = role.isCherryPicker(player.role) player.brain.nav.goTo(home, precision = nav.HOME, speed = nav.QUICK_SPEED, avoidObstacles = True, fast = fastWalk, pb = False) home = RobotLocation(player.homePosition.x, player.homePosition.y, player.homePosition.h) if (player.brain.sharedBall.ball_on and player.brain.sharedBall.reliability >= 2 and role.isDefender(player.role)): sharedball = Location(player.brain.sharedBall.x, player.brain.sharedBall.y) home.h = player.brain.loc.getRelativeBearing(sharedball) elif (player.brain.sharedBall.ball_on and player.brain.sharedBall.reliability >= 1 and role.isCherryPicker(player.role)): sharedball = Location(player.brain.sharedBall.x, player.brain.sharedBall.y) home.h = player.brain.loc.getRelativeBearing(sharedball) player.brain.nav.updateDest(home)
def positionAtHome(player): """ Go to the player's home position. Defenders look in the direction of the shared ball if it is on with reliability >= 2. Cherry pickers look in the direction of the shared ball if it is on with reliability >= 1. """ home = RobotLocation(player.homePosition.x, player.homePosition.y, player.homePosition.h) # if (player.brain.sharedBall.ball_on and player.brain.sharedBall.reliability >= 2 and # role.isDefender(player.role)): # sharedball = Location(player.brain.sharedBall.x, player.brain.sharedBall.y) # home.h = player.brain.loc.getRelativeBearing(sharedball) # elif (player.brain.sharedBall.ball_on and player.brain.sharedBall.reliability >= 1 and # role.isCherryPicker(player.role)): # sharedball = Location(player.brain.sharedBall.x, player.brain.sharedBall.y) # home.h = player.brain.loc.getRelativeBearing(sharedball) if player.firstFrame(): if role.isCherryPicker(player.role): player.brain.tracker.repeatWidePan() else: player.brain.tracker.trackBall() fastWalk = role.isCherryPicker(player.role) player.brain.nav.goTo(home, precision = nav.HOME, speed = nav.QUICK_SPEED, avoidObstacles = True, fast = fastWalk, pb = False) player.brain.nav.updateDest(home)
def positionAtHome(player): """ Go to the player's home position. Defenders look in the direction of the shared ball if it is on with reliability >= 2. Cherry pickers look in the direction of the shared ball if it is on with reliability >= 1. """ if role.isFirstChaser(player.role) and transitions.shouldFindSharedBall(player): return player.goLater('searchFieldForSharedBall') if player.brain.ball.vis.frames_off < 10: ball = player.brain.ball bearing = ball.bearing_deg elif player.brain.sharedBall.ball_on: ball = player.brain.sharedBall bearing = degrees(atan2(ball.y - player.brain.loc.y, ball.x - player.brain.loc.x)) - player.brain.loc.h else: ball = None home = player.homePosition if ball != None: if role.isLeftDefender(player.role): home = findDefenderHome(True, ball, bearing + player.brain.loc.h) elif role.isRightDefender(player.role): home = findDefenderHome(False, ball, bearing + player.brain.loc.h) elif role.isStriker(player.role): home = findStrikerHome(ball, bearing + player.brain.loc.h) else: home = player.homePosition if player.firstFrame(): if role.isCherryPicker(player.role): player.brain.tracker.repeatBasicPan() else: player.brain.tracker.trackBall() fastWalk = role.isChaser(player.role) player.brain.nav.goTo(home, precision = nav.HOME, speed = nav.QUICK_SPEED, avoidObstacles = True, fast = fastWalk, pb = False) player.brain.nav.updateDest(home)