コード例 #1
0
def Socket_command():
    for case in switch(socket_cmd.action):
        #-------PtP Mode--------
        if case(Taskcmd.Action_Type.PtoP):
            for case in switch(socket_cmd.setboth):
                if case(Taskcmd.Ctrl_Mode.CTRL_POS):
                    data = TCP.SetPtoP(socket_cmd.grip, Taskcmd.RA.ABS,
                                       Taskcmd.Ctrl_Mode.CTRL_POS, pos.x,
                                       pos.y, pos.z, pos.pitch, pos.roll,
                                       pos.yaw, socket_cmd.setvel)
                    break
                if case(Taskcmd.Ctrl_Mode.CTRL_EULER):
                    data = TCP.SetPtoP(socket_cmd.grip, Taskcmd.RA.ABS,
                                       Taskcmd.Ctrl_Mode.CTRL_EULER, pos.x,
                                       pos.y, pos.z, pos.pitch, pos.roll,
                                       pos.yaw, socket_cmd.setvel)
                    break
                if case(Taskcmd.Ctrl_Mode.CTRL_BOTH):
                    data = TCP.SetPtoP(socket_cmd.grip, Taskcmd.RA.ABS,
                                       Taskcmd.Ctrl_Mode.CTRL_BOTH, pos.x,
                                       pos.y, pos.z, pos.pitch, pos.roll,
                                       pos.yaw, socket_cmd.setvel)
                    break
            break
        #-------Line Mode--------
        if case(Taskcmd.Action_Type.Line):
            for case in switch(socket_cmd.setboth):
                if case(Taskcmd.Ctrl_Mode.CTRL_POS):
                    data = TCP.SetLine(socket_cmd.grip, Taskcmd.RA.ABS,
                                       Taskcmd.Ctrl_Mode.CTRL_POS, pos.x,
                                       pos.y, pos.z, pos.pitch, pos.roll,
                                       pos.yaw, socket_cmd.setvel)
                    break
                if case(Taskcmd.Ctrl_Mode.CTRL_EULER):
                    data = TCP.SetLine(socket_cmd.grip, Taskcmd.RA.ABS,
                                       Taskcmd.Ctrl_Mode.CTRL_EULER, pos.x,
                                       pos.y, pos.z, pos.pitch, pos.roll,
                                       pos.yaw, socket_cmd.setvel)
                    break
                if case(Taskcmd.Ctrl_Mode.CTRL_BOTH):
                    data = TCP.SetLine(socket_cmd.grip, Taskcmd.RA.ABS,
                                       Taskcmd.Ctrl_Mode.CTRL_BOTH, pos.x,
                                       pos.y, pos.z, pos.pitch, pos.roll,
                                       pos.yaw, socket_cmd.setvel)
                    break
            break
        #-------設定手臂速度--------
        if case(Taskcmd.Action_Type.SetVel):
            data = TCP.SetVel(socket_cmd.grip, socket_cmd.setvel)
            break
        #-------設定手臂Delay時間--------
        if case(Taskcmd.Action_Type.Delay):
            data = TCP.SetDelay(socket_cmd.grip, 0)
            break
        #-------設定手臂急速&安全模式--------
        if case(Taskcmd.Action_Type.Mode):
            data = TCP.Set_SpeedMode(socket_cmd.grip, socket_cmd.Speedmode)
            break
    socket_cmd.action = 5  ##切換初始mode狀態
    Socket.send(data.encode('utf-8'))  #socket傳送for python to translate str
コード例 #2
0
def Socket_command(s):
    global arm_mode_flag,data
    s = client()
    if arm_mode_flag ==  True:
        arm_mode_flag = False
        for case in switch(socket_cmd.action):
            #-------PtP Mode--------
            if case(Taskcmd.Action_Type.PtoP):
                for case in switch(socket_cmd.setboth):
                    if case(Taskcmd.Ctrl_Mode.CTRL_POS):
                        data = TCP.SetPtoP(socket_cmd.grip,Taskcmd.RA.ABS,Taskcmd.Ctrl_Mode.CTRL_POS,pos.x,pos.y,pos.z,pos.pitch,pos.roll,pos.yaw,socket_cmd.setvel)
                        break
                    if case(Taskcmd.Ctrl_Mode.CTRL_EULER):
                        data = TCP.SetPtoP(socket_cmd.grip,Taskcmd.RA.ABS,Taskcmd.Ctrl_Mode.CTRL_EULER,pos.x,pos.y,pos.z,pos.pitch,pos.roll,pos.yaw,socket_cmd.setvel)
                        break
                    if case(Taskcmd.Ctrl_Mode.CTRL_BOTH):
                        data = TCP.SetPtoP(socket_cmd.grip,Taskcmd.RA.ABS,Taskcmd.Ctrl_Mode.CTRL_BOTH,pos.x,pos.y,pos.z,pos.pitch,pos.roll,pos.yaw,socket_cmd.setvel)
                        break
                break
            #-------Line Mode--------
            if case(Taskcmd.Action_Type.Line):
                for case in switch(socket_cmd.setboth):
                    if case(Taskcmd.Ctrl_Mode.CTRL_POS):
                        data = TCP.SetLine(socket_cmd.grip,Taskcmd.RA.ABS,Taskcmd.Ctrl_Mode.CTRL_POS,pos.x,pos.y,pos.z,pos.pitch,pos.roll,pos.yaw,socket_cmd.setvel)
                        break
                    if case(Taskcmd.Ctrl_Mode.CTRL_EULER):
                        data = TCP.SetLine(socket_cmd.grip,Taskcmd.RA.ABS,Taskcmd.Ctrl_Mode.CTRL_EULER,pos.x,pos.y,pos.z,pos.pitch,pos.roll,pos.yaw,socket_cmd.setvel )
                        break
                    if case(Taskcmd.Ctrl_Mode.CTRL_BOTH):
                        data = TCP.SetLine(socket_cmd.grip,Taskcmd.RA.ABS,Taskcmd.Ctrl_Mode.CTRL_BOTH,pos.x,pos.y,pos.z,pos.pitch,pos.roll,pos.yaw,socket_cmd.setvel )
                        break
                break
            #-------設定手臂速度--------
            if case(Taskcmd.Action_Type.SetVel):
                data = TCP.SetVel(socket_cmd.grip, socket_cmd.setvel)
                break
            #-------設定手臂Delay時間--------
            if case(Taskcmd.Action_Type.Delay):
                data = TCP.SetDelay(socket_cmd.grip,0)
                break
            #-------設定手臂急速&安全模式--------
            if case(Taskcmd.Action_Type.Mode):
                data = TCP.Set_SpeedMode(socket_cmd.grip,socket_cmd.Speedmode)
                break
        socket_cmd.action= 6 ##切換初始mode狀態
        print(data)
        print("Socket:", s)
        #Socket.send(data.encode('utf-8'))#socket傳送for python to translate str
        s.send(data)
def socket_command():
    while(point_data_flag == True or arm_mode_flag == True or speed_mode_flag == True):
        ##---------------socket 傳輸手臂命令-----------------
        #-------選擇模式--------
        for case in switch(socket_cmd.action):
            #-------PtP Mode--------
            if case(Taskcmd.Action_Type.PtoP):
                for case in switch(socket_cmd.setboth):
                    if case(Taskcmd.Ctrl_Mode.CTRL_POS):
                        data = TCP.SetPtoP(socket_cmd.grip,Taskcmd.RA.ABS,Taskcmd.Ctrl_Mode.CTRL_POS,pos.x,pos.y,pos.z,pos.pitch,pos.roll,pos.yaw,socket_cmd.setvel)
                        break
                    if case(Taskcmd.Ctrl_Mode.CTRL_EULER):
                        data = TCP.SetPtoP(socket_cmd.grip,Taskcmd.RA.ABS,Taskcmd.Ctrl_Mode.CTRL_EULER,pos.x,pos.y,pos.z,pos.pitch,pos.roll,pos.yaw,socket_cmd.setvel)
                        break
                    if case(Taskcmd.Ctrl_Mode.CTRL_BOTH):
                        data = TCP.SetPtoP(socket_cmd.grip,Taskcmd.RA.ABS,Taskcmd.Ctrl_Mode.CTRL_BOTH,pos.x,pos.y,pos.z,pos.pitch,pos.roll,pos.yaw,socket_cmd.setvel)
                        break
                break
            #-------Line Mode--------
            if case(Taskcmd.Action_Type.Line):
                for case in switch(socket_cmd.setboth):
                    if case(Taskcmd.Ctrl_Mode.CTRL_POS):
                        data = TCP.SetLine(socket_cmd.grip,Taskcmd.RA.ABS,Taskcmd.Ctrl_Mode.CTRL_POS,pos.x,pos.y,pos.z,pos.pitch,pos.roll,pos.yaw,socket_cmd.setvel)
                        break
                    if case(Taskcmd.Ctrl_Mode.CTRL_EULER):
                        data = TCP.SetLine(socket_cmd.grip,Taskcmd.RA.ABS,Taskcmd.Ctrl_Mode.CTRL_EULER,pos.x,pos.y,pos.z,pos.pitch,pos.roll,pos.yaw,socket_cmd.setvel )
                        break
                    if case(Taskcmd.Ctrl_Mode.CTRL_BOTH):
                        data = TCP.SetLine(socket_cmd.grip,Taskcmd.RA.ABS,Taskcmd.Ctrl_Mode.CTRL_BOTH,pos.x,pos.y,pos.z,pos.pitch,pos.roll,pos.yaw,socket_cmd.setvel )
                        break
                break
            #-------設定手臂速度--------
            if case(Taskcmd.Action_Type.SetVel):
                data = TCP.SetVel(socket_cmd.grip, socket_cmd.setvel)
                break
            #-------設定手臂Delay時間--------
            if case(Taskcmd.Action_Type.Delay):
                data = TCP.SetDelay(socket_cmd.grip,0)
                break
            #-------設定手臂急速&安全模式--------
            if case(Taskcmd.Action_Type.Mode):
                data = TCP.Set_SpeedMode(socket_cmd.grip,socket_cmd.Speedmode)
                break
            return(data)
コード例 #4
0
def socket_client():
    global Socket, Arm_feedback, data, Socket_sent_flag
    try:
        Socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        Socket.connect(('192.168.0.1', 8080))  #iclab 5 & iclab hiwin
        #s.connect(('192.168.1.102', 8080))#iclab computerx
    except socket.error as msg:
        print(msg)
        sys.exit(1)
    print('Connection has been successful')
    print(Socket.recv(1024))
    #start_input=int(input('開始傳輸請按1,離開請按3 : ')) #輸入開始指令
    start_input = 1
    if start_input == 1:
        while 1:
            feedback_str = Socket.recv(1024)
            #手臂端傳送手臂狀態
            if str(feedback_str[2]) == '70':  # F 手臂為Ready狀態準備接收下一個運動指令
                Arm_feedback = 0
                socket_client_arm_state(Arm_feedback)
                #print("isbusy false")
            if str(feedback_str[2]) == '84':  # T 手臂為忙碌狀態無法執行下一個運動指令
                Arm_feedback = 1
                socket_client_arm_state(Arm_feedback)
                #print("isbusy true")
            if str(feedback_str[2]) == '54':  # 6 策略完成
                Arm_feedback = 6
                socket_client_arm_state(Arm_feedback)
                print("shutdown")
            #確認傳送旗標
            if str(feedback_str[4]) == '70':  #回傳0 false
                print(2222222222)
                Socket_sent_flag = False
                socket_client_sent_flag(Socket_sent_flag)
            if str(feedback_str[4]) == '84':  #回傳1 true
                print(111111111111)
                Socket_sent_flag = True
                socket_client_sent_flag(Socket_sent_flag)
                feedback_check = TCP.feedback_check()
                Socket.send(feedback_check.encode(
                    'utf-8'))  #socket傳送for python to translate str
        ##---------------socket 傳輸手臂命令 end-----------------
            if Arm_feedback == Taskcmd.Arm_feedback_Type.shutdown:
                break
    if start_input == 3:
        rospy.on_shutdown(myhook)
    rospy.on_shutdown(myhook)
    Socket.close()
コード例 #5
0
def socket_client():
    global Arm_feedback, data
    try:
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.connect(('192.168.0.1', 8080))  #iclab 5
        #s.connect(('192.168.1.102', 8080))#iclab computerx
    except socket.error as msg:
        print(msg)
        sys.exit(1)
    print('Connection has been successful')
    print(s.recv(1024))
    start_input = int(input('開始傳輸請按1,離開請按3 : '))
    #start_input = 1
    if start_input == 1:
        while 1:
            ##---------------socket 傳輸手臂命令-----------------
            for case in switch(socket_cmd.action):
                if case(Taskcmd.Action_Type.PtoP):
                    for case in switch(socket_cmd.setboth):
                        if case(Taskcmd.Ctrl_Mode.CTRL_POS):
                            data = TCP.SetPtoP(socket_cmd.grip, Taskcmd.RA.ABS,
                                               Taskcmd.Ctrl_Mode.CTRL_POS,
                                               pos.x, pos.y, pos.z, pos.pitch,
                                               pos.roll, pos.yaw,
                                               socket_cmd.setvel)
                            break
                        if case(Taskcmd.Ctrl_Mode.CTRL_EULER):
                            data = TCP.SetPtoP(socket_cmd.grip, Taskcmd.RA.ABS,
                                               Taskcmd.Ctrl_Mode.CTRL_EULER,
                                               pos.x, pos.y, pos.z, pos.pitch,
                                               pos.roll, pos.yaw,
                                               socket_cmd.setvel)
                            break
                        if case(Taskcmd.Ctrl_Mode.CTRL_BOTH):
                            data = TCP.SetPtoP(socket_cmd.grip, Taskcmd.RA.ABS,
                                               Taskcmd.Ctrl_Mode.CTRL_BOTH,
                                               pos.x, pos.y, pos.z, pos.pitch,
                                               pos.roll, pos.yaw,
                                               socket_cmd.setvel)
                            break
                    break
                if case(Taskcmd.Action_Type.Line):
                    for case in switch(socket_cmd.setboth):
                        if case(Taskcmd.Ctrl_Mode.CTRL_POS):
                            data = TCP.SetLine(socket_cmd.grip, Taskcmd.RA.ABS,
                                               Taskcmd.Ctrl_Mode.CTRL_POS,
                                               pos.x, pos.y, pos.z, pos.pitch,
                                               pos.roll, pos.yaw,
                                               socket_cmd.setvel)
                            break
                        if case(Taskcmd.Ctrl_Mode.CTRL_EULER):
                            data = TCP.SetLine(socket_cmd.grip, Taskcmd.RA.ABS,
                                               Taskcmd.Ctrl_Mode.CTRL_EULER,
                                               pos.x, pos.y, pos.z, pos.pitch,
                                               pos.roll, pos.yaw,
                                               socket_cmd.setvel)
                            break
                        if case(Taskcmd.Ctrl_Mode.CTRL_BOTH):
                            data = TCP.SetLine(socket_cmd.grip, Taskcmd.RA.ABS,
                                               Taskcmd.Ctrl_Mode.CTRL_BOTH,
                                               pos.x, pos.y, pos.z, pos.pitch,
                                               pos.roll, pos.yaw,
                                               socket_cmd.setvel)
                            break
                    break
                if case(Taskcmd.Action_Type.SetVel):
                    data = TCP.SetVel(socket_cmd.grip, socket_cmd.setvel)
                    break
                if case(Taskcmd.Action_Type.Delay):
                    data = TCP.SetDelay(socket_cmd.grip, 0)
                    break
                if case(Taskcmd.Action_Type.Mode):
                    data = TCP.SetMode()
                    break
            socket_cmd.action = 5
            s.send(data.encode('utf-8'))  #socket傳送for python to translate str
            feedback_str = s.recv(1024)
            #手臂端傳送手臂狀態
            ###test 0403
            if str(feedback_str[2]) == '70':  # F
                feedback = 0
                socket_client_arm_state(feedback)
                #print("isbusy false")
            if str(feedback_str[2]) == '84':  # T
                feedback = 1
                socket_client_arm_state(feedback)
                #print("isbusy true")
            if str(feedback_str[2]) == '54':  # 6
                feedback = 6
                socket_client_arm_state(feedback)
                print("shutdown")
            #Hiwin test 20190521
            # feedback = 0
            # socket_client_arm_state(feedback)
            #Hiwin test 20190521
            Arm_feedback = TCP.Is_busy(feedback)
            ###test 0403
            ##---------------socket 傳輸手臂命令 end-----------------
            if Arm_feedback == Taskcmd.Arm_feedback_Type.shutdown:
                rospy.on_shutdown(myhook)
                break
    if start_input == 3:
        pass
    s.close()
def socket_client():
    global Arm_feedback, data, Socket_sent_flag
    try:
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.connect(('192.168.0.1', 8080))  #iclab 5 & iclab hiwin
        #s.connect(('192.168.1.102', 8080))#iclab computerx
    except socket.error as msg:
        print(msg)
        sys.exit(1)
    print('Connection has been successful')
    print(s.recv(1024))
    #start_input=int(input('開始傳輸請按1,離開請按3 : ')) #輸入開始指令
    start_input = 1
    if start_input == 1:
        while 1:
            ##---------------socket 傳輸手臂命令-----------------
            #if Arm_feedback == 0:
            if Socket_sent_flag == True:
                Socket_sent_flag = False
                #-------選擇模式--------
                for case in switch(socket_cmd.action):
                    #-------PtP Mode--------
                    if case(Taskcmd.Action_Type.PtoP):
                        for case in switch(socket_cmd.setboth):
                            if case(Taskcmd.Ctrl_Mode.CTRL_POS):
                                data = TCP.SetPtoP(socket_cmd.grip,
                                                   Taskcmd.RA.ABS,
                                                   Taskcmd.Ctrl_Mode.CTRL_POS,
                                                   pos.x, pos.y, pos.z,
                                                   pos.pitch, pos.roll,
                                                   pos.yaw, socket_cmd.setvel)
                                break
                            if case(Taskcmd.Ctrl_Mode.CTRL_EULER):
                                data = TCP.SetPtoP(
                                    socket_cmd.grip, Taskcmd.RA.ABS,
                                    Taskcmd.Ctrl_Mode.CTRL_EULER, pos.x, pos.y,
                                    pos.z, pos.pitch, pos.roll, pos.yaw,
                                    socket_cmd.setvel)
                                break
                            if case(Taskcmd.Ctrl_Mode.CTRL_BOTH):
                                data = TCP.SetPtoP(socket_cmd.grip,
                                                   Taskcmd.RA.ABS,
                                                   Taskcmd.Ctrl_Mode.CTRL_BOTH,
                                                   pos.x, pos.y, pos.z,
                                                   pos.pitch, pos.roll,
                                                   pos.yaw, socket_cmd.setvel)
                                break
                        break
                    #-------Line Mode--------
                    if case(Taskcmd.Action_Type.Line):
                        for case in switch(socket_cmd.setboth):
                            if case(Taskcmd.Ctrl_Mode.CTRL_POS):
                                data = TCP.SetLine(socket_cmd.grip,
                                                   Taskcmd.RA.ABS,
                                                   Taskcmd.Ctrl_Mode.CTRL_POS,
                                                   pos.x, pos.y, pos.z,
                                                   pos.pitch, pos.roll,
                                                   pos.yaw, socket_cmd.setvel)
                                break
                            if case(Taskcmd.Ctrl_Mode.CTRL_EULER):
                                data = TCP.SetLine(
                                    socket_cmd.grip, Taskcmd.RA.ABS,
                                    Taskcmd.Ctrl_Mode.CTRL_EULER, pos.x, pos.y,
                                    pos.z, pos.pitch, pos.roll, pos.yaw,
                                    socket_cmd.setvel)
                                break
                            if case(Taskcmd.Ctrl_Mode.CTRL_BOTH):
                                data = TCP.SetLine(socket_cmd.grip,
                                                   Taskcmd.RA.ABS,
                                                   Taskcmd.Ctrl_Mode.CTRL_BOTH,
                                                   pos.x, pos.y, pos.z,
                                                   pos.pitch, pos.roll,
                                                   pos.yaw, socket_cmd.setvel)
                                break
                        break
                    #-------設定手臂速度--------
                    if case(Taskcmd.Action_Type.SetVel):
                        data = TCP.SetVel(socket_cmd.grip, socket_cmd.setvel)
                        break
                    #-------設定手臂Delay時間--------
                    if case(Taskcmd.Action_Type.Delay):
                        data = TCP.SetDelay(socket_cmd.grip, 0)
                        break
                    #-------設定手臂急速&安全模式--------
                    if case(Taskcmd.Action_Type.Mode):
                        data = TCP.Set_SpeedMode(socket_cmd.grip,
                                                 socket_cmd.Speedmode)
                        break
                socket_cmd.action = 5  ##切換初始mode狀態
                s.send(
                    data.encode('utf-8'))  #socket傳送for python to translate str
            feedback_str = s.recv(1024)
            #手臂端傳送手臂狀態
            if str(feedback_str[2]) == '70':  # F 手臂為Ready狀態準備接收下一個運動指令
                Arm_feedback = 0
                socket_client_arm_state(Arm_feedback)
                #print("isbusy false")
            if str(feedback_str[2]) == '84':  # T 手臂為忙碌狀態無法執行下一個運動指令
                Arm_feedback = 1
                socket_client_arm_state(Arm_feedback)
                #print("isbusy true")
            if str(feedback_str[2]) == '54':  # 6 策略完成
                Arm_feedback = 6
                socket_client_arm_state(Arm_feedback)
                print("shutdown")
            #確認傳送旗標
            if str(feedback_str[4]) == '48':  #回傳0 false
                Socket_sent_flag = False
            if str(feedback_str[4]) == '49':  #回傳1 true
                Socket_sent_flag = True
        ##---------------socket 傳輸手臂命令 end-----------------
            if Arm_feedback == Taskcmd.Arm_feedback_Type.shutdown:
                rospy.on_shutdown(myhook)
                break
    if start_input == 3:
        pass
    s.close()
コード例 #7
0
def socket_command():
    while 1:
        ##---------------socket 傳輸手臂命令-----------------
        #-------選擇模式--------
        for case in switch(socket_cmd.action):
            #-------PtP Mode--------
            if case(Taskcmd.Action_Type.PtoP):
                for case in switch(socket_cmd.setboth):
                    if case(Taskcmd.Ctrl_Mode.CTRL_POS):
                        data = TCP.SetPtoP(socket_cmd.grip, Taskcmd.RA.ABS,
                                           Taskcmd.Ctrl_Mode.CTRL_POS, pos.x,
                                           pos.y, pos.z, pos.pitch, pos.roll,
                                           pos.yaw, socket_cmd.setvel)
                        break
                    if case(Taskcmd.Ctrl_Mode.CTRL_EULER):
                        data = TCP.SetPtoP(socket_cmd.grip, Taskcmd.RA.ABS,
                                           Taskcmd.Ctrl_Mode.CTRL_EULER, pos.x,
                                           pos.y, pos.z, pos.pitch, pos.roll,
                                           pos.yaw, socket_cmd.setvel)
                        break
                    if case(Taskcmd.Ctrl_Mode.CTRL_BOTH):
                        data = TCP.SetPtoP(socket_cmd.grip, Taskcmd.RA.ABS,
                                           Taskcmd.Ctrl_Mode.CTRL_BOTH, pos.x,
                                           pos.y, pos.z, pos.pitch, pos.roll,
                                           pos.yaw, socket_cmd.setvel)
                        break
                break
            #-------Line Mode--------
            if case(Taskcmd.Action_Type.Line):
                for case in switch(socket_cmd.setboth):
                    if case(Taskcmd.Ctrl_Mode.CTRL_POS):
                        data = TCP.SetLine(socket_cmd.grip, Taskcmd.RA.ABS,
                                           Taskcmd.Ctrl_Mode.CTRL_POS, pos.x,
                                           pos.y, pos.z, pos.pitch, pos.roll,
                                           pos.yaw, socket_cmd.setvel)
                        break
                    if case(Taskcmd.Ctrl_Mode.CTRL_EULER):
                        data = TCP.SetLine(socket_cmd.grip, Taskcmd.RA.ABS,
                                           Taskcmd.Ctrl_Mode.CTRL_EULER, pos.x,
                                           pos.y, pos.z, pos.pitch, pos.roll,
                                           pos.yaw, socket_cmd.setvel)
                        break
                    if case(Taskcmd.Ctrl_Mode.CTRL_BOTH):
                        data = TCP.SetLine(socket_cmd.grip, Taskcmd.RA.ABS,
                                           Taskcmd.Ctrl_Mode.CTRL_BOTH, pos.x,
                                           pos.y, pos.z, pos.pitch, pos.roll,
                                           pos.yaw, socket_cmd.setvel)
                        break
                break
            #-------設定手臂速度--------
            if case(Taskcmd.Action_Type.SetVel):
                data = TCP.SetVel(socket_cmd.grip, socket_cmd.setvel)
                break
            #-------設定手臂Delay時間--------
            if case(Taskcmd.Action_Type.Delay):
                data = TCP.SetDelay(socket_cmd.grip, 0)
                break
            #-------設定手臂急速&安全模式--------
            if case(Taskcmd.Action_Type.Mode):
                data = TCP.Set_SpeedMode(socket_cmd.grip, socket_cmd.Speedmode)
                break
        socket_cmd.action = 5  ##切換初始mode狀態
        s.send(data.encode('utf-8'))  #socket傳送for python to translate str
        feedback_str = s.recv(1024)
        #手臂端傳送手臂狀態
        if str(feedback_str[2]) == '70':  # F 手臂為Ready狀態準備接收下一個運動指令
            Arm_feedback = 0
            socket_client_arm_state(Arm_feedback)
            #print("isbusy false")
        if str(feedback_str[2]) == '84':  # T 手臂為忙碌狀態無法執行下一個運動指令
            Arm_feedback = 1
            socket_client_arm_state(Arm_feedback)
            #print("isbusy true")
        if str(feedback_str[2]) == '54':  # 6 策略完成
            Arm_feedback = 6
            socket_client_arm_state(Arm_feedback)
            print("shutdown")
    ##---------------socket 傳輸手臂命令 end-----------------
        if Arm_feedback == Taskcmd.Arm_feedback_Type.shutdown:
            rospy.on_shutdown(myhook)
            break