def calcTargetXY(target_x, target_y): print "target_x: %3.3fcm, target_y: %3.3fcm" % (target_x, target_y) # determine kicking leg side = target_y < 0 # 0 = LEFT, 1 = RIGHT print "Designated kick leg: %s" % (side==LEFT and "LEFT" or "RIGHT") # calculate optimal kicking point kp_x, kp_y = target_x - KICK_X_OPT[side], target_y - KICK_Y_OPT[side] kp_dist, kp_bearing = cart2polar(kp_x, kp_y) print "kp_x: %3.3fcm kp_y: %3.3fcm" % (kp_x, kp_y) print "kp_dist: %3.3fcm kp_bearing: %3.3f" % (kp_dist, kp_bearing) # ball location, as defined at behavior parameters (front, side, etc...) target_location = calcBallArea(target_x, target_y, side) print ('TARGET_IN_KICKING_AREA', 'TARGET_BETWEEN_LEGS', 'TARGET_FRONT_NEAR', 'TARGET_FRONT_FAR','TARGET_SIDE_NEAR', 'TARGET_SIDE_FAR', 'TARGET_DIAGONAL')[target_location] # by Vova - new kick TODO: use consts, add explanation of meaning, perhaps move inside adjusted_straight_kick (passing ball, of course) kick_side_offset = 1.1-1.2*(abs(target_y-KICK_Y_MIN[side])/7) return side, kp_x, kp_y, kp_dist, kp_bearing, target_location, kick_side_offset