def device_once_test():
    pibo = Edu_Pibo()
    print('확인할 device를 입력하세요.(system, battery) (q: 종료)')

    while True:
        cmd = input("")
        if cmd == "q":
            break
        ret = pibo.check_device(cmd)
        print(ret)
def translate_test():
    pibo = Edu_Pibo()

    print('한->영: 번역할 문장을 입력하세요. (q: 종료)')
    while True:
        string = input('입력: ')
        if string == "q":
            break
        ret = pibo.translate(string, to="en")
        print("번역:", ret["data"])
Example #3
0
def tts_test():
    pibo = Edu_Pibo()

    filename = cfg.TESTDATA_PATH + "/tts.mp3"
    ret = pibo.tts(
        "<speak><voice name='WOMAN_READ_CALM'>안녕. 나는 파이보야.<break time='500ms'/></voice></speak>",
        filename)
    print(ret)
    pibo.play_audio(filename, out='local', volume=-1500)
    time.sleep(2)
Example #4
0
def motor_test():
    pibo = Edu_Pibo()
    while True:
        pibo.motor(2, 30, 100, 10)
        pibo.motor(8, 30, accel=10)
        time.sleep(1)

        pibo.motor(2, -30, 100, 10)
        pibo.motor(8, -30, speed=70)
        time.sleep(1)
Example #5
0
def talk_test():
    pibo = Edu_Pibo()

    print('대화를 시작합니다. (q: 종료)')
    while True:
        question = input('나: ')
        if question == 'q':
            break

        ans = pibo.conversation(question)
        print('파이보: ', ans["data"])
def get_code():
    pibo = Edu_Pibo()

    time.sleep(0.5)
    print('조회하고 싶은 errcode를 입력하세요.(숫자) (q: 종료)')
    while True:
        user_input = input()

        if user_input == 'q':
            return
        print(pibo.get_codeMean(int(user_input)))
def capture_test():
    pibo = Edu_Pibo()

    # Version 1. Camera on
    pibo.start_camera()
    time.sleep(1)
    pibo.capture()
    time.sleep(3)
    pibo.stop_camera()

    # Version 2. Camera off
    pibo.capture("capture_cameraoff.png")
Example #8
0
def get_motion():
    pibo = Edu_Pibo()
    motion_list = pibo.get_motion()
    print(motion_list['data'])

    time.sleep(0.5)
    print('모션을 입력하면 해당 모션의 정보를 조회할 수 있습니다.(q: 종료)')
    while True:
        user_input = input('입력: ')

        if user_input == 'q':
            return
        info = pibo.get_motion(user_input)
        pprint.pprint(info['data'])
Example #9
0
def detect_test():
    pibo = Edu_Pibo()

    pibo.start_camera()
    time.sleep(2)
    obj = pibo.search_object()
    qr = pibo.search_qr()
    text = pibo.search_text()
    print("Search Object: ", obj)
    print("Search QR: ", qr)
    print("Search Text: ", text)
    pibo.stop_camera()
def color_test():
    pibo = Edu_Pibo()
    pibo.start_camera()
    time.sleep(2)
    color = pibo.search_color()
    print("Search Color: ", color)
    pibo.stop_camera()
Example #11
0
def image_test():
    pibo = Edu_Pibo()

    ret = pibo.draw_image(cfg.TESTDATA_PATH + "/clear.png")
    print(ret)
    pibo.show_display()
    time.sleep(2)
    pibo.clear_display()
Example #12
0
def text_test():
    pibo = Edu_Pibo()

    ret = pibo.draw_text((10, 10), '안녕하세요. Hello', 15)
    print(ret)
    pibo.show_display()
    time.sleep(2)
    pibo.clear_display()
def face_test():
    pibo = Edu_Pibo()

    pibo.start_camera()
    time.sleep(3)
    face = pibo.search_face()
    print(face)
    pibo.stop_camera()
def movetime_test():
    pibo = Edu_Pibo()
    while True:
        pibo.motors_movetime(positions=[0,0,30,20, 30,0, 0,0,30,20], movetime=1000)
        time.sleep(1)
        pibo.motors_movetime(positions=[0,0,-30,-20, -30,0, 0,0,-30,-20])
        time.sleep(1)
def color_name_test():
    pibo = Edu_Pibo()
    ret = pibo.eye_on('aqua', 'purple')
    print(ret)
    time.sleep(1)

    ret2 = pibo.eye_on('pink')
    print(ret2)
    time.sleep(1)
    pibo.eye_off()
def motors_test():
    pibo = Edu_Pibo()
    while True:
        pibo.motors(positions=[0, 0, 0, 10, 0, 10, 0, 0, 0, 20],
                    speed=[0, 0, 0, 15, 0, 10, 0, 0, 0, 10],
                    accel=[0, 0, 10, 5, 0, 0, 0, 0, 5, 10])
        time.sleep(1)

        pibo.motors(
            positions=[0, 0, 0, -10, 0, -10, 0, 0, 0, -20],
            speed=[0, 0, 0, 15, 0, 10, 0, 0, 0, 10],
        )
        time.sleep(1)
def train_face_test():
    pibo = Edu_Pibo()
    print("Start DB:", pibo.get_facedb()["data"][0])

    # Train face
    pibo.start_camera()
    time.sleep(2)
    pibo.train_face("Kim")
    print("After Train, DB:", pibo.get_facedb()["data"][0])
    pibo.stop_camera()

    # Recognize
    pibo.start_camera()
    time.sleep(2)
    ret = pibo.search_face()
    print("Recognize: ", ret["data"])
    pibo.stop_camera()

    # Save DB
    pibo.save_facedb('./facedb')
    
    # Reset DB
    # pibo.init_facedb()
    # print('After reset db, DB: ', pibo.get_facedb()["data"][0])

    # Load DB
    pibo.load_facedb()
    print('After Load db, DB: ', pibo.get_facedb()["data"][0])

    # Delete Face
    ret=pibo.delete_face("Kim")
    print('After Delete face: ', pibo.get_facedb()["data"][0])
Example #18
0
        sys._getframe(0).f_code.co_name, len(faces)))

    return len(faces)


def device(msg):
    LOG_PRINT('{}: {}'.format(sys._getframe(0).f_code.co_name, msg))

    if "person" in msg["PIR"]:
        if check_person() > 0:
            listen()


if __name__ == "__main__":
    LOG_PRINT("Start")
    pibo = Edu_Pibo()
    LOG_PRINT("Init ...")

    pibo.draw_image(cfg.TESTDATA_PATH + "/icon/pibo_logo.png")
    pibo.show_display()

    play_tts("안녕! 난 파이보야.")
    pibo.set_motion("welcome", 1)
    pibo.set_motion("stop", 1)

    LOG_PRINT("Device Start ...")

    while True:
        _, res = pibo.check_device("system")
        device(res)
        time.sleep(1)
Example #19
0
def audio_test():
    pibo = Edu_Pibo()
    ret=pibo.play_audio(filename=cfg.TESTDATA_PATH+"/test.mp3", out='local', volume=-2000)
    print(ret)
    time.sleep(3)
    pibo.stop_audio()
def figure_test():
    pibo = Edu_Pibo()
    pibo.draw_figure((10, 10, 30, 30), "rectangle", True)
    pibo.draw_figure((70, 40, 90, 60), "circle", False)
    pibo.draw_figure((15, 15, 80, 50), "line")
    pibo.show_display()
    time.sleep(1.5)

    pibo.invert()
    pibo.show_display()
    time.sleep(1.5)
    pibo.clear_display()
Example #21
0
import os, sys, time, random

sys.path.append(os.path.dirname(os.path.abspath(os.path.dirname(__file__))))
from utils.config import Config as cfg

sys.path.append(cfg.OPENPIBO_PATH + '/edu')
from pibo import Edu_Pibo


def msg_device(msg):
    print(msg)


def device_test():
    ret = pibo.start_devices(msg_device)
    print(ret)


if __name__ == "__main__":
    pibo = Edu_Pibo()
    device_test()

    while True:
        cmd = [random.randint(0, 255) for i in range(6)]
        pibo.eye_on(*cmd)
Example #22
0
def device_thread_test():
    pibo = Edu_Pibo()
    ret = pibo.start_devices(msg_device)
    print(ret)
    time.sleep(12)
    pibo.stop_devices()
Example #23
0
def stt_test():
    pibo = Edu_Pibo()

    ret = pibo.stt()
    print(ret)
Example #24
0
def add_color():
    pibo = Edu_Pibo()
    print("Start colorDB: ", pibo.get_colordb())

    # add_color
    ret = pibo.add_color("black", 1, 1, 1)   # 기본으로 제공하는 목록에 있는 컬러
    print("Add black", ret)
    pibo.add_color("brown", 150,75,0) 

    # Save DB
    pibo.save_colordb('./new_colordb')
    pibo.load_colordb('new_colordb')
    print("Add brown: ", pibo.get_colordb()["data"])

    # add_color2
    pibo.add_color("lime", 191,255,0)
    pibo.save_colordb('./new_colordb')
    pibo.load_colordb('new_colordb')
    print("Add lime: ", pibo.get_colordb()["data"])
    
    # Delete color
    pibo.delete_color('brown')
    pibo.save_colordb('./new_colordb')
    pibo.load_colordb('new_colordb')
    print("Delete brown: ", pibo.get_colordb()["data"])

    pibo.eye_on('lime')
    time.sleep(2)
    pibo.eye_off()
Example #25
0
    text = pibo.search_text()
    print("Search Object: ", obj)
    print("Search QR: ", qr)
    print("Search Text: ", text)

    time.sleep(3)

    # 얼굴 인식
    pibo.start_camera()
    time.sleep(3)
    face = pibo.search_face()
    print('face: ', face)

    time.sleep(3)

    # 얼굴 학습
    pibo.start_camera()
    time.sleep(3)
    pibo.train_face()


if __name__ == "__main__":
    pibo = Edu_Pibo()
    audio_test()
    # neopixel_test()
    # device_test()
    # motion_tset()
    # oled_test()
    # speech_test()
    # camera_test()
def streaming_test():
    pibo = Edu_Pibo()

    pibo.start_camera()
    time.sleep(3)
    pibo.stop_camera()
def motion_test():
    pibo = Edu_Pibo()
    ret = pibo.set_motion("dance1", 2)
    print(ret)