Beispiel #1
0
 def draw_Ui_Ur_Add_Pose(cur_loc, cur_rot):
     try:
         draw_Done_Pose_Obj = Bl_Ui_Draw_Pose.draw_Pose(cur_loc, cur_rot)
         bod.data_Set_Pose(draw_Done_Pose_Obj)
         bod.data_Set_Save_Curr_Ur_Pose(cur_loc, cur_rot)
         Bl_Ui_Draw_Pose.draw_Pose_Path()
     except Exception as e:
         print("draw_Ui_Ur_Add_Pose",e)
 def bcall_Save_Pose_Lists(self, widget):
     print("Button '{0}' is pressed".format(widget.text))
     try:
         bof.FLAG_IK_MOVE_DRAG = False
         bod.data_Set_Save_To_Mem()
         Bl_Ui_Draw_Pose_Operator(0)
         bpy.ops.object.dialog_operator('INVOKE_DEFAULT')
     except Exception as e:
         print(e)
Beispiel #3
0
 def draw_Del_Pose():
     try:
         Bl_Ui_Draw_Pose.draw_Reset()
         bod.data_Reset_Pose()
         bpy.ops.object.select_pattern(pattern="pos*", extend=False)
         bpy.ops.object.delete()
         bpy.ops.object.select_pattern(pattern="cur_motion_path*", extend=False)
         bpy.ops.object.delete()
     except Exception as e:
         print("draw_Del_Pose",e)
Beispiel #4
0
 def draw_Load_File_Ur_Add_Pose(load_pose_datas):
     try:
         for load_pose_data in load_pose_datas:
             load_Ur_Loc     = load_pose_data[0]
             load_Ur_Rot     = load_pose_data[1]
             load_Ur_Time    = load_pose_data[2]
             load_Ur_Radius  = load_pose_data[3]
             load_Ur_Gripper = load_pose_data[4]
             draw_Done_Pose_Obj = Bl_Ui_Draw_Pose.draw_Pose(load_Ur_Loc, load_Ur_Rot)
             bod.data_Set_Pose(draw_Done_Pose_Obj,load_Ur_Time,load_Ur_Radius,load_Ur_Gripper)
     except Exception as e:
         print("draw_Load_File_Ur_Add_Pose",e)
Beispiel #5
0
 def draw_Load_File_Data_Add_Pose(file_Data):
     try:
         bod.data_Reset_Pose()
         file_Load_Data = bod.data_Split_Load_Ur_Pose(file_Data)
         Bl_Ui_Draw_Pose.draw_Del_Pose()
         Bl_Ui_Draw_Pose.draw_Load_File_Ur_Add_Pose(file_Load_Data)
         Bl_Ui_Draw_Pose.draw_Pose_Path()
         Bl_Ui_Draw_Pose.draw_Reset()
     except Exception as e:
         print("draw_Load_file_Data_Add_Pose",e)
     finally:
         bof.FLAG_IK_MOVE_DRAG = True
Beispiel #6
0
    def execute(self, context):
        message = ("What you typed : {}".format(self.Name))
        self.report({'INFO'}, message)
        save_Pose_Data = bod.data_Get_Save_To_File()
        print(save_Pose_Data)

        if save_Pose_Data:  # Datas => jointangle_Datas
            write_File = open("{}/{}.txt".format(self.DataPath, self.Name),
                              'w')
            write_File.write(str(save_Pose_Data))
            write_File.close()
        bof.FLAG_IK_MOVE_DRAG = True

        return {'FINISHED'}
Beispiel #7
0
    def draw_Curr_Ur_FK():
        curr_Ur_Angle = bod.data_Get_Curr_Ur_Angle()
        if curr_Ur_Angle:
            Base = curr_Ur_Angle[1]
            Shoulder = curr_Ur_Angle[2]
            Elbow = curr_Ur_Angle[3]
            Wrist1 = curr_Ur_Angle[4]
            Wrist2 = curr_Ur_Angle[5]
            Wrist3 = curr_Ur_Angle[6]

            bpy.data.objects['Armature_UR'].pose.bones[
                'Base'].rotation_euler.y = Base + 1.57079
            bpy.data.objects['Armature_UR'].pose.bones[
                'Shoulder'].rotation_euler.y = Shoulder + 1.5708
            bpy.data.objects['Armature_UR'].pose.bones[
                'Elbow'].rotation_euler.y = -Elbow
            bpy.data.objects['Armature_UR'].pose.bones[
                'Wrist1'].rotation_euler.y = Wrist1 + 1.5708
            bpy.data.objects['Armature_UR'].pose.bones[
                'Wrist2'].rotation_euler.y = Wrist2
            bpy.data.objects['Armature_UR'].pose.bones[
                'Wrist3'].rotation_euler.y = Wrist3
 def up_Down_On_Ur_Accel_Up_Down_Value_Change(self, up_down, value): # on_ur_accel_up_down_value_change
     bod.data_Set_Ui_Ur_Accel(value)
     print("up_Down__On_Ur_Accel_Up_Down_Value_Change",bod.data_Get_Ui_Ur_Accel())
 def up_Down_On_Ur_Velo_Up_Down_Value_Change(self, up_down, value): # up_Down_On_Ur_Accel_Up_Down_Value_Change
     bod.data_Set_Ui_Ur_Velo(value)
     print("up_Down__On_Ur_Velo_Up_Down_Value_Change : ",bod.data_Get_Ui_Ur_Velo())
 def bcall_Set_Velo_Accel(self, widget):
     print("Button '{0}' is pressed".format(widget.text))
     velo = bod.data_Get_Ui_Ur_Velo()
     accel = bod.data_Get_Ui_Ur_Accel()
     URxMoveToPoseOperator(13, velo, accel)
 def bcall_Run_Motion(self, widget):
     try:
         print("Button '{0}' is pressed".format(widget.text))
         bod.data_Generate_Job()
     except Exception as message:
         print("bcall_run_Motion error : ", message)
Beispiel #12
0
    def recv(self, client, addr, deviceName):
        while (True):
            try:

                recv_data = client.recv(self.max_bytes)
                length = len(recv_data)
                # print("\n$$$", length, type(recv_data))

                # 데이터 길이 및 유무 확인 후 없다면 연결 종료
                if not recv_data:
                    print("Disconnected by - ", deviceName, ':', addr[0], ':',
                          addr[1])
                    self.del_Client(deviceName)
                    client.close()
                    break

                # 디바이스 명이 XAVIER 일 경우 받은 데이터 처리
                if deviceName == 'XAVIER':
                    buffer = recv_data.decode()
                    print("XAVIER Read : {}".format(buffer))
                    print(type(buffer))
                    if buffer == '1' and self.FLAG_AUTO_CONTROL_MODE == True and self.FLAG_STATE_UR_RUN == False:
                        try:
                            print("debug XAVIER Read")
                            self.auto_ModeLists = self.auto_ModeLoadNumber
                            self.auto_ModeListCount = self.auto_ModeListCount + 1
                            self.FLAG_CHECK_XAVIER_DATA = True
                            self.FLAG_STATE_UR_RUN = True
                            print("debug XAVIER Read out ")
                        except Exception as e:
                            print(e)

                    # 이미지 처리 부분
                    # buffer = recv_data
                    # if (length > self.max_bytes - 1) or (length == 8):
                    #     # Image_LENGTH + jpg_IMAGE
                    #     # print(recv_data[0:8])
                    #     try:
                    #         img_length = int(buffer[0:8])  # TRY False(str or bytes)
                    #         len_data = img_length - length - 8
                    #         self.xavier_Image_Datas = buffer[8:] + self.recv_All(client, len_data)
                    #
                    #         # for end
                    #     except:
                    #         # print(">>> int change error !")
                    #         pass
                    #         try:
                    #             str_data = buffer[0:6].decode()
                    #             # print(str_data)
                    #             # print(">>>",length,type(str_data)) #'str'
                    #         except:
                    #             pass
                    #             # print(">>> str change error !")
                    #
                    # # 포즈 처리 부분
                    # else:
                    #     if self.FLAG_CLOUD_POINT == True:  # self.FLAG_CLOUD_POINT 가 True 일 경우만 포즈 데이터를 저장
                    #         try:
                    #             xavierPoseData = buffer.decode()
                    #             if (length < 3):
                    #                 print("> none data")
                    #             elif (length < 7):
                    #                 str_data = xavierPoseData
                    #                 print("> Server check")
                    #             else:
                    #                 print(xavierPoseData)
                    #                 self.lock.acquire()  # 스레드 락 (테스트후 삭제 예정)
                    #                 self.xavier_Pose_Datas = xavierPoseData
                    #                 self.lock.release()
                    #                 self.FLAG_CLOUD_POINT = False
                    #                 print("self.FLAG_CLOUD_POINT", self.FLAG_CLOUD_POINT)
                    #         except:
                    #             print(">>> data Error !!")
                    #print("XAVIER Read : {}".format(recv_data))

                # 디바이스 명이 ROBOT 일 경우 받은 데이터 처리
                elif deviceName == 'ROBOT':
                    buffer = recv_data.decode()
                    if buffer == "fw":
                        print("Work is finished")
                    else:
                        buffer_ = eval(buffer)
                        if buffer_[0] == 0:
                            curr_Ur_State = buffer_
                            bod.robot1.robot_Set_Curr_Ur_State(curr_Ur_State)
                            # print("ROBOT State Read : {}".format(buffer_))
                        if buffer_[0] == 1:
                            curr_Ur_Angle = buffer_
                            bod.data_Set_Curr_Ur_Angle(curr_Ur_Angle)

                # 디바이스 명이 EMC 일 경우 받은 데이터 처리 비상시 긴급 정지를 위해 ROBOT에서 스레드로 계속 확인
                elif deviceName == 'EMC':
                    buffer = recv_data.decode()
                    print("EMC Read : {}".format(buffer))

                # 디바이스 명 없이 접속
                else:
                    buffer = recv_data.decode()
                    print("Unkown Device Name Read : {}".format(buffer))
                    print("Unkown Device Name Disconnected by - ", addr[0],
                          ':', addr[1])
                    client.close()
                    break

            except Exception as e:
                print("Something's wrong : {}".format(e))
                client.close()
                self.del_Client(deviceName)
                break
Beispiel #13
0
def URxMoveToPoseOperator(code, cmd1=0, cmd2=0, cmd3=0):
    #ik_target = bpy.data.objects['IK Target']
    if (code == 0):  #"Home Posistion"
        print("debug : URxMoveToPoseOperator code : 0 , Home")
        bl_Server.set_Off_Teach_Mode()
        bl_Server.move_Home()

    elif (code == 1):  #right "Run" btn
        print("debug : URxMoveToPoseOperator code : 1 , Run")
        time = cmd1
        radius = cmd2
        gMotion = cmd3
        armature_obj = bpy.data.objects['Armature_ik']

        robotMode = "movej"
        if (robotMode == "movej"):
            bl_Server.movej(bod.data_Split_Local_Orientation(armature_obj),
                            time, radius, gMotion)
        elif (robotMode == "speedj"):
            print("debug code 1")
            bl_Server.speedj(
                bod.data_Split_Local_Orientation(armature_obj.pose.bones))

    elif (code == 2):  #"STOP" btn
        print("debug : URxMoveToPoseOperator code : 2 , STOP")
        bl_Server.emergency()

    elif (code == 3):
        print("debug : ")

    elif (code == 4):
        print("debug : ")

    elif (code == 5):
        print("debug : ")

    elif (code == 6):  #"PROGRAM_shut_Down"
        print("debug : URxMoveToPoseOperator code : 6 , PROGRAM_shut_Down")
        bl_Server.shut_Down()

    elif (code == 7):
        print("debug : ")

    elif (code == 8):
        print("debug : ")

    elif (code == 9):
        print("debug : ")

    elif (code == 10):
        print("debug : ")

    elif (code == 11):
        print("debug : ")

    elif (code == 12):
        print("debug : ")

    elif (code == 13):  # "set_Velo"
        print("debug : URxMoveToPoseOperator code : 13 , set_Velo")
        bl_Server.set_Velo(cmd1, cmd2)

    elif (code == 14):
        print("debug : ")

    elif (code == 15):
        print("debug : ")

    return {'FINISHED'}
Beispiel #14
0
def my_callback(scene, context):
    file_List = bod.data_Get_File_List()
    return file_List
 def up_Down_On_Ur_Move_Time_Up_Down_Value_Change(self, up_down, value):
     bod.data_Set_Ui_Ur_Time(value)
     print("up_Down__On_Ur_Move_Time_Up_Down_Value_Change : ",bod.data_Get_Ui_Ur_Time())
Beispiel #16
0
    def set_event(self, event, context):
        if event.type == 'P' and event.value == 'PRESS':
            if self.is_rotation:
                print('rotation off')
                self.is_rotation = False
            else:
                print('rotation On')
                self.is_rotation = True

        if event.type == 'MOUSEMOVE':
            if self.is_drag:
                self.x = (event.mouse_x - self.drag_offset_x) / 2000
                self.z = self._urChangePoseY
                self.y = (event.mouse_y - self.drag_offset_y) / 2000
                # print('cur x=',self.x,' y=',self.y)
                if self.x > 0.5 or self.y > 0.5:
                    self.is_drag = False
                    self.drag_offset_x = 0
                    self.drag_offset_y = 0
                    # print('release')
                    self.mover.stop_command(IKMover.CMD_MOVE)
                else:
                    if self.is_rotation:
                        self.mover._setRotate(self.x, self.z, self.y)
                    else:
                        self.mover._setCurPos(self.x, self.z, self.y)
                    self.mover.start_command(IKMover.CMD_MOVE)
                return

        if bof.FLAG_IK_MOVE_DRAG == True:
            if event.type == 'LEFTMOUSE':
                if event.value == 'PRESS':
                    self.is_drag = True
                    self.drag_offset_x =  event.mouse_x
                    self.drag_offset_y =  event.mouse_y
                    area = bpy.context.window_manager.windows[0].screen.areas[0]
                    viewport = area.regions[0]
                    if viewport is not None:
                        pass

                elif event.value == 'RELEASE':
                    self.is_drag = False
                    self.mover.stop_command(IKMover.CMD_MOVE)
                    if self.is_rotation: # roation mode
                        self.item._set_rotation(self.mover.cur_roatation)
                    else: # axis move mode
                        self.item._set_new_pos(self.mover.cur_location)
                
        if event.type == 'RIGHTMOUSE':
            if event.value == 'PRESS':
                budp.draw_Ui_Ur_Add_Pose(self.mover.cur_location, self.mover.cur_roatation)

        if event.type == 'H' and event.value == 'PRESS':
            bod.data_Switch_Camera_Loc_Rot_Value(6.5, -60, 5.4, 90, 0, 0)

        if event.type == 'W' and event.value == 'PRESS':
            bpy.ops.transform.translate(value=(0, 0, -1), orient_type='LOCAL')

        if event.type == 'S' and event.value == 'PRESS':
            bpy.ops.transform.translate(value=(0, 0, 1), orient_type='LOCAL')

        if event.type == 'D' and event.value == 'PRESS':
            bpy.ops.transform.translate(value=(1, 0, 0), orient_type='LOCAL')

        if event.type == 'A' and event.value == 'PRESS':
            bpy.ops.transform.translate(value=(-1, 0, 0), orient_type='LOCAL')

        if event.type == 'Q' and event.value == 'PRESS':
            bpy.ops.transform.rotate(value=0.01, orient_axis='Y', orient_type='LOCAL')

        if event.type == 'E' and event.value == 'PRESS':
            bpy.ops.transform.rotate(value=-0.01, orient_axis='Y', orient_type='LOCAL')

        if event.type == 'R' and event.value == 'PRESS':
            bpy.ops.transform.rotate(value=0.01, orient_axis='X', orient_type='LOCAL')

        if event.type == 'F' and event.value == 'PRESS':
            bpy.ops.transform.rotate(value=-0.01, orient_axis='X', orient_type='LOCAL')
 def up_Down_On_Ur_Move_Radius_Up_Down_Value_Change(self, up_down, value):
     bod.data_Set_Ui_Ur_Radius(value / 100)
     print("up_Down__On_Ur_Move_Radius_Up_Down_Value_Change : ", bod.data_Get_Ui_Ur_Radius())
Beispiel #18
0
    def set_event(self, event, context):
        if event.type == 'R' and event.value == 'PRESS':
            if self.is_rotation:
                print('rotation off')
                self.is_rotation = False
            else:
                print('rotation On')
                self.is_rotation = True

        if event.type == 'MOUSEMOVE':
            if self.is_drag:
                self.x = (event.mouse_x - self.drag_offset_x) / 20000
                self.z = 0  # self.mover.bound_location[1]
                self.y = (event.mouse_y - self.drag_offset_y) / 20000
                # print('cur x=',self.x,' y=',self.y)
                if self.x > 0.5 or self.y > 0.5:
                    self.is_drag = False
                    self.drag_offset_x = 0
                    self.drag_offset_y = 0
                    # print('release')
                    self.mover.stop_command(IKMover.CMD_MOVE)
                else:
                    if self.is_rotation:
                        self.mover._setRotate(self.x, self.z, self.y)
                    else:
                        self.mover._setCurPos(self.x, self.z, self.y)
                    self.mover.start_command(IKMover.CMD_MOVE)
                return

        if bof.FLAG_IK_MOVE_DRAG == True:
            if event.type == 'LEFTMOUSE':
                if event.value == 'PRESS':
                    self.is_drag = True
                    self.drag_offset_x = event.mouse_x
                    self.drag_offset_y = event.mouse_y
                    area = bpy.context.window_manager.windows[0].screen.areas[
                        0]
                    #print('IK location = ',self.mover.bound_location)
                    viewport = area.regions[0]
                    if viewport is not None:
                        pass
                        #print('region ', viewport.x,viewport.y,viewport.width,viewport.height)
                        #region3D = context.space_data.region_3d
                        #loc = region_2d_to_location_3d(viewport, region3D, (event.mouse_x, event.mouse_y), (0, 0, 0))
                        #print('press',self.drag_offset_x,' ', self.drag_offset_y,' loc =',loc)
                    #    self.mover.bound_location = loc

                elif event.value == 'RELEASE':
                    self.is_drag = False

                    #print('release')
                    self.mover.stop_command(IKMover.CMD_MOVE)
                    if self.is_rotation:  # roation mode
                        self.item._set_rotation(self.mover.cur_roatation)
                    else:  # axis move mode
                        self.item._set_new_pos(self.mover.cur_location)

        if event.type == 'RIGHTMOUSE' or event.type == 'NUMPAD_0':
            if event.value == 'PRESS':
                print("self.mover.cur_location : ", self.mover.cur_location,
                      "self.mover.cur_roatation : ", self.mover.cur_roatation)
                budp.draw_Ui_Ur_Add_Pose(self.mover.cur_location,
                                         self.mover.cur_roatation)

        if event.type == 'ONE' and event.value == 'PRESS':
            #bod.data_Switch_Camera_Loc_Rot_Value(0.09822, -3.724, 0.683, 90, 0, 0)
            bod.data_Switch_Camera_Loc_Rot_Value(0.17039, -3.54293, 0.66801,
                                                 90, 0, 0)

        if event.type == 'TWO' and event.value == 'PRESS':
            bod.data_Switch_Camera_Loc_Rot_Value(2.68753, -1.96311, 3.67556,
                                                 50.4, 0, 44)

        if event.type == 'THREE' and event.value == 'PRESS':
            bod.data_Switch_Camera_Loc_Rot_Value(4.60415, 0.55412, 2.69870,
                                                 66.8, 0, 90)

        if event.type == 'FOUR' and event.value == 'PRESS':
            bod.data_Switch_Camera_Loc_Rot_Value(-3.02668, -1.35379, 3.77938,
                                                 50, 0, -62)

        if event.type == 'FIVE' and event.value == 'PRESS':
            bod.data_Switch_Camera_Loc_Rot_Value(-3.94804, 0.31245, 2.39620,
                                                 66.8, 0, -90)

        if event.type == 'NUMPAD_PERIOD':
            if event.value == 'PRESS':
                self.urManualControlFlag = True
                print(self.urManualControlFlag)

        if event.type in self.command_for_key_type:
            action = self.action_for_key_state[event.value]
            action(self.command_for_key_type[event.type])