def waitForKick(wm): print(readWM(wm, "comms")) messages = readWM(wm, "comms") for key in messages: if messages[key]["msg"] == "Kick": return True return False
def waitForStand(wm): print(readWM(wm, "comms")) messages = readWM(wm, "comms") for key in messages: if messages[key]["msg"] == "Stand": return True return False
def noSeeBall(wm): camera_data_balls = readWM(wm, "balls") if not largestBall(wm)["pa"] == None: print (largestBall(wm)["pa"]) if largestBall(wm)["pa"] <= 70: print(largestBall(wm)["pa"], "no ball") return True else: return False
def noSeeBall(wm): camera_data_balls = readWM(wm, "balls") if largestBall(wm) == None: return False elif largestBall(wm)["pa"] <= 200: print(largestBall(wm)['camera'] , "noSeeBall") return True else: return False
def seeBall(wm): camera_data_balls = readWM(wm, "balls") if largestBall(wm) == None: return False elif largestBall(wm)["pa"] >= 200: print(largestBall(wm)['camera'], "SeeBall") return True else: return False
def largestBall(wm): camera_data_balls = readWM(wm,"balls") if not camera_data_balls: return None else: # Get the latest observation cur_frame = camera_data_balls[0] # The object with the largest area is most likely the true ball largest_ball1 = None for b1 in cur_frame: if ( not largest_ball1 ) or (largest_ball1["pa"] < b1["pa"]): largest_ball1 = b1 return largest_ball1
def seeNao(wm): camera_data_goals = readWM(wm, "goals") if not camera_data_goals: return False else: # Get the latest observation cur_frame = camera_data_goals[0] # The object with the largest area is most likely the true goal for b1 in cur_frame: if (currentTime(wm) - b1["t"]) <= 0.5: print("naoSize", b1["pa"]) if b1["pa"] <= 2000 and b1["pa"] >= 200: return True return False
def seeNao(wm): camera_data_goals = readWM(wm,"goals") if not camera_data_goals: return False else: # Get the latest observation cur_frame = camera_data_goals[0] # The object with the largest area is most likely the true goal for b1 in cur_frame: if (currentTime(wm) - b1["t"]) <= 0.5: print ("naoSize", b1["pa"]) if b1["pa"] <= 2000 and b1["pa"] >= 200: return True return False
def lookAtBall2(wm): camera_data_balls = readWM(wm,"balls") if not camera_data_balls: return None else: # Get the latest observation cur_frame = camera_data_balls[0] # The object with the largest area is most likely the true ball largest_ball = None for b1 in cur_frame: if (not largest_ball) or (largest_ball["pa"] < b1["pa"]): largest_ball = b1 if largest_ball["pa"] > 100: return turnHead(largest_ball["yaw"], largest_ball["pitch"])
def largestBall(wm): camera_data_balls = readWM(wm, "balls") if not camera_data_balls: return False else: # Get the latest observation cur_frame = camera_data_balls[0] # The object with the largest area is most likely the true ball largest_ball1 = [] for b1 in cur_frame: if (currentTime(wm) - b1["t"]) <= 0.5: if b1["pa"] > 100: largest_ball1 += [b1] return largest_ball1
def lookAtBall2(wm): camera_data_balls = readWM(wm, "balls") if not camera_data_balls: return None else: # Get the latest observation cur_frame = camera_data_balls[0] # The object with the largest area is most likely the true ball largest_ball = None for b1 in cur_frame: if (not largest_ball) or (largest_ball["pa"] < b1["pa"]): largest_ball = b1 if largest_ball["pa"] > 100: return turnHead(largest_ball["yaw"], largest_ball["pitch"])
def largestBall(wm): camera_data_balls = readWM(wm,"balls") if not camera_data_balls: return False else: # Get the latest observation cur_frame = camera_data_balls[0] # The object with the largest area is most likely the true ball largest_ball1 = [] for b1 in cur_frame: if (currentTime(wm) - b1["t"]) <= 0.5: if b1["pa"] > 100: largest_ball1 += [b1] return largest_ball1
def largestGoal(wm): camera_data_goals = readWM(wm, "goals") if not camera_data_goals: return None else: # Get the latest observation cur_frame = camera_data_goals[0] # The object with the largest area is most likely the true goal largest_goal = None for b1 in cur_frame: if (not largest_goal) or (largest_goal["pa"] < b1["pa"]): largest_goal = b1 if largest_goal["pa"] > 2500: return largest_goal else: return None
def largestGoal(wm): camera_data_goals = readWM(wm,"goals") if not camera_data_goals: return None else: # Get the latest observation cur_frame = camera_data_goals[0] # The object with the largest area is most likely the true goal largest_goal = None for b1 in cur_frame: if (not largest_goal) or (largest_goal["pa"] < b1["pa"]): largest_goal = b1 if largest_goal["pa"] > 2500: return largest_goal else: return None
def averageLook(wm): camera_data_balls = readWM(wm, "balls") if not camera_data_balls: return None else: largest_ball2 = None second_frame = camera_data_balls[1] for b in second_frame: if (not largest_ball2) or (largest_ball2["pa"] < b["pa"]): largest_ball2 = b largest_ball3 = None third_frame = camera_data_balls[2] for c in third_frame: if (not largest_ball3) or (largest_ball3["pa"] < c["pa"]): largest_ball3 = c pitch_average = (largestBall(wm)["pitch"] + largest_ball2["pitch"] + largest_ball3["pitch"]) / 3 yaw_average = (largestBall(wm)["yaw"] + largest_ball2["yaw"] + largest_ball3["yaw"]) / 3 return [yaw_average, pitch_average]
def currentTime(wm): return readWM(wm, "time", "current")
def entryTime(wm): return readWM(wm, "time", "entry")
def waitForKick(wm): messages = readWM(wm, "comms") for key in messages: if messages[key]["msg"] == "Kick": return True return False
def waitForFindBall(wm): messages = readWM(wm, "comms") for key in messages: if messages[key]["msg"] == "Find ball": return True return False
def detectTouch(wm): return readWM(wm, "tactile", "middle")
def touchDelay(wm): return ((currentTime(wm) - entryTime(wm)) > 3) and readWM( wm, "tactile", "middle")
def waitForSit(wm): messages = readWM(wm, "comms") for key in messages: if messages[key]["msg"] == "Sit": return True return False
def touchDelay(wm): return ((currentTime(wm) - entryTime(wm)) > 3) and readWM(wm, "tactile", "middle")