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 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()
def color_test(): pibo = Edu_Pibo() pibo.start_camera() time.sleep(2) color = pibo.search_color() print("Search Color: ", color) pibo.stop_camera()
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])
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 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()
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"])
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)
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)
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 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 talk_test(): pibo = Edu_Pibo() print('대화를 시작합니다. (q: 종료)') while True: question = input('나: ') if question == 'q': break ans = pibo.conversation(question) print('파이보: ', ans["data"])
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()
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")
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 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 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'])
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()
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)
def stt_test(): pibo = Edu_Pibo() ret = pibo.stt() print(ret)
def streaming_test(): pibo = Edu_Pibo() pibo.start_camera() time.sleep(3) pibo.stop_camera()
def device_thread_test(): pibo = Edu_Pibo() ret = pibo.start_devices(msg_device) print(ret) time.sleep(12) pibo.stop_devices()
def motion_test(): pibo = Edu_Pibo() ret = pibo.set_motion("dance1", 2) print(ret)