コード例 #1
0
def waitForKick(wm):
    print(readWM(wm, "comms"))
    messages = readWM(wm, "comms")
    for key in messages:
        if messages[key]["msg"] == "Kick":
            return True
    return False
コード例 #2
0
def waitForStand(wm):
    print(readWM(wm, "comms"))
    messages = readWM(wm, "comms")
    for key in  messages:
        if messages[key]["msg"] == "Stand":
            return True
    return False
コード例 #3
0
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
コード例 #4
0
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
コード例 #5
0
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
コード例 #6
0
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
コード例 #7
0
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
コード例 #8
0
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
コード例 #9
0
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"])
コード例 #10
0
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
コード例 #11
0
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"])
コード例 #12
0
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
コード例 #13
0
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
コード例 #14
0
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
コード例 #15
0
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]
コード例 #16
0
def currentTime(wm):
    return readWM(wm, "time", "current")
コード例 #17
0
def entryTime(wm):
    return readWM(wm, "time", "entry")
コード例 #18
0
def waitForKick(wm):
    messages = readWM(wm, "comms")
    for key in messages:
        if  messages[key]["msg"] == "Kick":
            return True
    return False
コード例 #19
0
def waitForFindBall(wm):
    messages = readWM(wm, "comms")
    for key in messages:
        if messages[key]["msg"] == "Find ball":
            return True
    return False
コード例 #20
0
def detectTouch(wm):
    return readWM(wm, "tactile", "middle")
コード例 #21
0
def touchDelay(wm):
    return ((currentTime(wm) - entryTime(wm)) > 3) and readWM(
        wm, "tactile", "middle")
コード例 #22
0
def waitForSit(wm):
    messages = readWM(wm, "comms")
    for key in messages:
        if messages[key]["msg"] == "Sit":
            return True
    return False
コード例 #23
0
def waitForFindBall(wm):
    messages = readWM(wm, "comms")
    for key in messages:
        if messages[key]["msg"] == "Find ball":
            return True
    return False
コード例 #24
0
def touchDelay(wm):
    return ((currentTime(wm) - entryTime(wm)) > 3) and readWM(wm, "tactile", "middle")