コード例 #1
0
def program(robot: robot.Robot):

    if robot.lift_height.distance_mm > 45:
        with robot.perform_off_charger():
            robot.set_lift_height(0.0).wait_for_completed()
    count = ['three', 'two', 'one']
    say = ['rock', 'paper', 'scissors']

    for i in range(3):
        robot.say_text(say[i])
        robot.display_oled_face_image(pics[count[i]], 1000,
                                      True).wait_for_completed()
    robot.say_text('shoot')
    robot.display_oled_face_image(pics['scissors'], 1000,
                                  True).wait_for_completed()
    time.sleep(2.0)

    for i in range(3):
        throw_input = input("Enter gesture (r / p / s): ")
        while throw_input not in ['r', 'p', 's']:
            print("Invalid input! Try again!")
            throw_input = input("Enter gesture (r / p / s): ")

        if throw_input == 'r':
            robot.display_oled_face_image(pics['rock'], 1000, False)

        elif throw_input == 'p':
            robot.display_oled_face_image(pics['paper'], 1000, False)

        else:
            robot.display_oled_face_image(pics['scissors'], 1000, False)
コード例 #2
0
ファイル: test-control.py プロジェクト: markchen1357/cozmo
def disp_count_down(robot, pics):
    print("3, 2, 1, shoot!")
    # TODO: show count down
    count = ['three', 'two', 'one']
    say = ['rock', 'paper', 'scissors']

    for i in range(3):
        robot.say_text(say[i], use_cozmo_voice = ROBOT_VOICE)
        robot.display_oled_face_image(pics[count[i]], 1000, True).wait_for_completed()
    robot.say_text('shoot', use_cozmo_voice = ROBOT_VOICE) 
コード例 #3
0
def disp_throw(robot, pics, throw, current):
    throw_dict = ['rock', 'paper', 'scissors']
    symbol = throw_dict[throw]

    if current:
        if not current.is_completed:
            current.abort()

    print('Robot throws {}'.format(symbol))

    return robot.display_oled_face_image(pics['rock'], 50000, True)