Ejemplo n.º 1
0
def SpeechTriggerShaking():
    global wait_for_enter_flag, adjust_pos_flag
    while True:
        # Record Audio
        r = sr.Recognizer()
        with sr.Microphone() as source:
            r.adjust_for_ambient_noise(source, duration=0.5)
            print("Say something!")
            audio = r.listen(source)
            # Speech recognition using Google Speech Recognition
        try:
            shake_cont.cmd_str = r.recognize_google(audio, language='zh-TW')
            shake_cont.move_str = shake_cont.cmd_str
            if Hiwin_Shake_Strategy.CheckCmd():
                break
        except sr.UnknownValueError:
            print("Google Speech Recognition could not understand audio")
        except sr.RequestError as e:
            print(
                "Could not request results from Google Speech Recognition service; {0}"
                .format(e))
    shake_cont.Hiwin_Move_Log.StartWrite('')
    shake_cont.Hiwin_Move_Log.WriteDate()
    Hiwin_Shake_Strategy.SmartShaking(Hiwin_Action)
    tk.messagebox.showinfo(title='Finished!',
                           message='Time used:\n  {:.0f} m {:.2f} s'.format(
                               (time() - shake_cont.start_time) // 60,
                               (time() - shake_cont.start_time) % 60))
    shake_cont.Home(Hiwin_Action)
    wait_for_enter_flag = False
    adjust_pos_flag = False
Ejemplo n.º 2
0
def PosCollate():
    shake_cont.InitData(shake_cont.delt_z)
    pos_list = [
        shake_cont.Home_Pos, shake_cont.Full_Ice_Pos, shake_cont.Above_Ice_Pos,
        shake_cont.Above_Duo_Duo_Pos, shake_cont.Duo_Duo_Pos,
        shake_cont.Above_Duo_Duo_Pos, shake_cont.Above_Dong_Gua_T_Pos,
        shake_cont.Dong_Gua_T_Pos, shake_cont.Above_Dong_Gua_T_Pos,
        shake_cont.Above_Blace_T_Pos, shake_cont.Blace_T_Pos,
        shake_cont.Above_Blace_T_Pos, shake_cont.Above_Green_T_Pos,
        shake_cont.Green_T_Pos, shake_cont.Above_Green_T_Pos,
        shake_cont.Above_Lid_Pos, shake_cont.Back_Sugar_Pos,
        shake_cont.Above_Sugar_Unspined_Pos,
        shake_cont.Above_Sugar_Unspined_Pos, shake_cont.Back_Sugar_Pos
    ]
    pause_list = [1, 4, 7, 10, 13, 18]
    shake_cont.SpeedModeToggle(1)
    for i in range(len(pos_list)):
        shake_trig.Hiwin_Action.ArmMove(
            pos_list[i], collate_speed, 0,
            'test point({}/{})'.format(i + 1, len(pos_list)))
        # shake_cont.Animation_Action.ArmMove(pos_list[i],20,0,'test point({}/{})'.format(i+1,len(pos_list)))
        if i in pause_list:
            tk.messagebox.showinfo(message='Next Point?')
    tk.messagebox.showinfo(message='Collation Finished!')
    # shake_cont.Home(shake_cont.Animation_Action)
    shake_cont.Home(shake_trig.Hiwin_Action)
    shake_cont.InitData(-shake_cont.delt_z)
Ejemplo n.º 3
0
def CoordinateCollation():
    while 1:
        input("左下定位")
        shake_cont.Left(Hiwin_Action)
        input("右上定位")
        shake_cont.Right(Hiwin_Action)
        if input('OK?') == '1':
            shake_cont.Home(Hiwin_Action)
            break
Ejemplo n.º 4
0
def Shake():
    global wait_for_enter_flag, adjust_pos_flag
    if Hiwin_Shake_Strategy.CheckCmd():
        shake_cont.move_str = shake_cont.cmd_str
        shake_cont.Hiwin_Move_Log.StartWrite('Real Action')
        shake_cont.Hiwin_Move_Log.WriteDate()
        Hiwin_Shake_Strategy.SmartShaking(Hiwin_Action)
        tk.messagebox.showinfo(
            title='Finished!',
            message='Time used:\n  {:.0f} m {:.2f} s'.format(
                (time() - shake_cont.start_time) // 60,
                (time() - shake_cont.start_time) % 60))
        shake_cont.Home(Hiwin_Action)
    wait_for_enter_flag = False
    adjust_pos_flag = False
Ejemplo n.º 5
0
 def BackHome():
     collate.destroy()
     # shake_cont.Home(shake_cont.Animation_Action)
     shake_cont.Home(shake_trig.Hiwin_Solo_Action)
Ejemplo n.º 6
0
 def BackHome():
     collate.destroy()
     shake_cont.Home(shake_cont.Animation_Action)
Ejemplo n.º 7
0
 def CollateOK():
     collate.destroy()
     shake_cont.Home(shake_cont.Animation_Action)
Ejemplo n.º 8
0
 def BackHome():
     shake_cont.pos_ok_flag = True
     pos_adjust.destroy()
     shake_cont.Home(shake_trig.Hiwin_Action)