def execute(param, state, bot_id, pub): botPos = Vector2D(int(state.homePos[bot_id].x), int(state.homePos[bot_id].y)) ballPos = Vector2D(int(state.ballPos.x), int(state.ballPos.y)) destPoint = Vector2D(int(param.KickToPointP.x), int(param.KickToPointP.y)) ob = Vector2D() finalSlope = destPoint.angle(botPos) turnAngleLeft = ob.normalizeAngle( finalSlope - state.homePos[bot_id].theta) #Angle left to turn dist = ballPos.dist(botPos) if dist > BOT_BALL_THRESH: sGoToBall.execute(param, state, bot_id, pub) return if math.fabs(turnAngleLeft ) > SATISFIABLE_THETA / 2: # SATISFIABLE_THETA in config file sParam = skills_union.SParam() sParam.TurnToPointP.x = destPoint.x sParam.TurnToPointP.y = destPoint.y sParam.TurnToPointP.max_omega = MAX_BOT_OMEGA * 3 sTurnToPoint.execute(sParam, state, bot_id, pub) return skill_node.send_command(pub, state.isteamyellow, bot_id, 0, 0, 0, param.KickToPointP.power, False)
def execute(self, state, pub): target = Vector2D(int(0), int(0)) ballPos = Vector2D(int(state.ballPos.x), int(state.ballPos.y)) botPos = Vector2D(int(state.homePos[self.bot_id].x), int(state.homePos[self.bot_id].y)) flag = 0 theta = atan2((ballPos.y - target.y), (ballPos.x - target.x)) if ballPos.dist(botPos) > 2 * BOT_RADIUS: x1 = BOT_RADIUS * cos(theta) + float(state.ballPos.x) y1 = BOT_RADIUS * sin(theta) + float(state.ballPos.y) fpoint = Vector2D(int(x1), int(y1)) x2 = -BOT_RADIUS * cos(theta) + float(state.ballPos.x) y2 = -BOT_RADIUS * sin(theta) + float(state.ballPos.y) spoint = Vector2D(int(x2), int(y2)) fix = Vector2D() if target.dist(fpoint) > target.dist(spoint): fix.x = int(fpoint.x) fix.y = int(fpoint.y) else: fix.x = int(spoint.x) fix.y = int(spoint.y) #angleToTurn = ballPos.normalizeAngle((ballPos.angle(botPos))-(state.homePos[bot_id].theta)) print "*******BALL POS " + str(ballPos.x) + " " + str(ballPos.y) print "#####FIX POINT " + str(fix.x) + " " + str(fix.y) self.sParam.GoToPointP.x = fix.x self.sParam.GoToPointP.y = fix.y self.sParam.GoToPointP.finalslope = ballPos.angle(target) self.sParam.GoToPointP.align = True sGoToPoint.execute(self.sParam, state, self.bot_id, pub) print "################GOTOPOINT WHEN SELECTING POINT##############" elif ballPos.dist(botPos) < 2 * BOT_RADIUS and ballPos.dist( botPos) > BOT_RADIUS: self.sParam.GoToBallP.intercept = False #may be true sGoToBall.execute(self.sParam, state, self.bot_id, pub) print "###############GOTOBALL################" elif ballPos.dist(botPos) <= BOT_RADIUS: self.sParam.GoToPointP.x = target.x self.sParam.GoToPointP.y = target.y self.sParam.GoToPointP.finalslope = ballPos.angle(target) self.sParam.GoToPointP.align = True sGoToPoint.execute(self.sParam, state, self.bot_id, pub) print "#################GOING FOR TARGET########"
def execute(param, state, bot_id): botPos = Vector2D(state.homePos[bot_id].x, state.homePos[bot_id].y) ballPos = Vector2D(state.ballPos.x, state.ballPos.y) destPoint = Vector2D(param.KickToPointP.x, param.KickToPointP.y) ob = Vector2D() finalSlope = ob.angle(destPoint, botPos) turnAngleLeft = ob.normalizeAngle( finalSlope - state.homePos[bot_id].theta) #Angle left to turn dist = ob.dist(ballPos, botPos) if dist > BOT_BALL_THRESH: sGoToBall.execute(param, state, bot_id) if math.fabs(turnAngleLeft ) > SATISFIABLE_THETA / 2: # SATISFIABLE_THETA in config file paramt = Sparam() paramt.TurnToPointP.x = destPoint.x paramt.TurnToPointP.y = destPoint.y paramt.TurnToPointP.max_omega = MAX_BOT_OMEGA * 3 sTurnToPoint.execute(paramt, state, bot_id) skill_node.send_command(state.isteamyellow, bot_id, 0, 0, 0, param.KickToPointP.power, False)
import skill_node import maths import sGoToBall import sTurnToPoint def execute(param, state, bot_id): botPos=Vector2D(state.homePos[bot_id].x, state.homePos[bot_id].y) ballPos=Vector2D(state.ballPos.x, state.ballPos.y) destPoint=Vector2D(param.KickToPointP.x, param.KickToPointP.y) ob = Vector2D() finalSlope = ob.angle(destPoint, botPos) turnAngleLeft = ob.normalizeAngle(finalSlope - state.homePos[bot_id].theta) #Angle left to turn dist = ob.dist(ballPos, botPos) if dist > BOT_BALL_THRESH : return sGoToBall.execute(param,state,bot_id) if math.fabs(turnAngleLeft) > SATISFIABLE_THETA/2 : # SATISFIABLE_THETA in config file Sparam paramt() paramt.TurnToPointP.x = destPoint.x paramt.TurnToPointP.y = destPoint.y paramt.TurnToPointP.max_omega = MAX_BOT_OMEGA*3 return sTurnToPoint.execute(paramt, state, bot_id) skill_node.send_command(state.isteamyellow, bot_id ,0, 0, 0, param.KickToPointP.power, False)
def execute(self, state, pub): #add all parameters markBotID = self.param.IntercptP.awayBotID markBot = Vector2D(int(state.homePos[markBotID].x), int(state.homePos[markBotID].y)) botPos = Vector2D(int(state.homePos[self.bot_id].x), int(state.homePos[self.bot_id].y)) ballpos = Vector2D(int(state.ballPos.x), int(state.ballPos.y)) passerBotID = -1 mindis = -1.0 TEAMSIZE = 5 for i in range(TEAMSIZE): if i != self.bot_id and i != markBotID: bot = Vector2D(int(state.homePos[i].x), int(state.homePos[i].y)) dis = bot.dist(ballpos) if 0.0 > mindis: mindis = dis passerBotID = i elif dis < mindis: mindis = dis #ASK passerBotID = i #ASK passerBot = Vector2D(int(state.homePos[passerBotID].x), int(state.homePos[passerBotID].y)) #goal_point is the point which will be blocked by the intercepter OUR_GOAL_X = 500 goal_point = Vector2D(int(OUR_GOAL_X), int(0)) destination = Vector2D() destinationSlope = Vector2D() ballFromBot = ballpos.dist(botPos) ballFromPasser = ballpos.dist(passerBot) ballFromMark = ballpos.dist(markBot) global ballFromOpp if ballFromPasser > ballFromMark: ballFromOpp = ballFromMark / 1.0 else: ballFromOpp = ballFromPasser / 1.0 if ballFromOpp < ballFromBot: if self.param.IntercptP.where == 0: destination.x = int(0.7 * markBot.x + 0.3 * passerBot.x) destination.y = int( 0.7 * markBot.y + 0.3 * passerBot.y) #0.7 * markBot + 0.3 * passerBot else: destination.x = int(0.7 * markBot.x + 0.3 * goal_point.x) destination.y = int(0.7 * markBot.y + 0.3 * goal_point.y) destinationSlope = passerBot.angle(botPos) pointFromBot = botPos.dist(destination) global iState if pointFromBot > BOT_BALL_THRESH: iState = 1 #"GOTOPOSITION" else: if pointFromBot <= DRIBBLER_BALL_THRESH: iState = 2 #"GOTOBALL" else: iState = 1 #"GOTOPOSTION" else: if ballFromBot > DRIBBLER_BALL_THRESH: iState = 2 #"GOTOBALL" else: iState = 3 #"CLEAR" if iState is 1: #call here gotoPosition self.sParam.GoToPointP.x = destination.x self.sParam.GoToPointP.y = destination.y self.sParam.GoToPointP.finalVelocity = MAX_BOT_SPEED self.sParam.GoToPointP.finalslope = destinationSlope self.sParam.GoToPointP.align = False sGoToPoint.execute(self.sParam, state, self.bot_id, pub) return elif iState is 2: #call here gotoBall self.sParam.GoToBallP.intercept = False sGoToBall.execute(self.sParam, state, self.bot_id, pub) return elif iState is 3: #call here clear self.sParam.KickP.power = 10 sKick.execute(self.sParam, state, self.bot_id, pub) return