Exemple #1
0
    def GetPose_UpdateWindow(self) -> dict:
        """
        姿勢を取得し、ウインドウを更新する関数

        Return:
            CurrentPose (dict): Dobotの現在の姿勢
        """

        pose = dType.GetPose(self.api)  # 現在のDobotの位置と関節角度を取得
        for num, key in enumerate(self.CurrentPose.keys()):
            self.CurrentPose[key] = pose[num]

        self.Window["-Get_JointPose1-"].update(
            str(self.CurrentPose["joint1Angle"]))
        self.Window["-Get_JointPose2-"].update(
            str(self.CurrentPose["joint2Angle"]))
        self.Window["-Get_JointPose3-"].update(
            str(self.CurrentPose["joint3Angle"]))
        self.Window["-Get_JointPose4-"].update(
            str(self.CurrentPose["joint4Angle"]))
        self.Window["-Get_CoordinatePose_X-"].update(str(
            self.CurrentPose["x"]))
        self.Window["-Get_CoordinatePose_Y-"].update(str(
            self.CurrentPose["y"]))
        self.Window["-Get_CoordinatePose_Z-"].update(str(
            self.CurrentPose["z"]))
        self.Window["-Get_CoordinatePose_R-"].update(str(
            self.CurrentPose["r"]))

        return self.CurrentPose
Exemple #2
0
    def GetPose_UpdateWindow(self):
        """
        姿勢を取得し、ウインドウを更新する関数

        Parameters
        ----------
        api : Dobot型
            DobotAPIのコンストラクタ
        Window
            PySimpleGUIのウインドウ画面
        """

        pose = dType.GetPose(self.api)  # 現在のDobotの位置と関節角度を取得
        pose = dict(zip(self.pose_key, pose))  # 辞書形式に変換

        self.Window["-JointPose1-"].update(str(pose["joint1Angle"]))
        self.Window["-JointPose2-"].update(str(pose["joint2Angle"]))
        self.Window["-JointPose3-"].update(str(pose["joint3Angle"]))
        self.Window["-JointPose4-"].update(str(pose["joint4Angle"]))
        self.Window["-CoordinatePose_X-"].update(str(pose["x"]))
        self.Window["-CoordinatePose_Y-"].update(str(pose["y"]))
        self.Window["-CoordinatePose_Z-"].update(str(pose["z"]))
        self.Window["-CoordinatePose_R-"].update(str(pose["r"]))

        return pose
Exemple #3
0
def Operation(api, file_name, axis, volume=1, initPOS=None):
    """
        A function that sends a motion command in any direction

        Parameters
        ----------
        api : CDLL
        axis : str
            移動方向
        volume : int
            移動量
        """
    axis_list = ["x", "y", "z", "r"]
    if initPOS != None:
        pose = initPOS
    else:
        pose = dType.GetPose(api)

    if axis in axis_list:
        if axis == "x":
            _OneAction(api, pose[0] + volume, pose[1], pose[2], pose[3])
        elif axis == "y":
            _OneAction(api, pose[0], pose[1] + volume, pose[2], pose[3])
        elif axis == "z":
            _OneAction(api, pose[0], pose[1], pose[2] + volume, pose[3])
        else:
            print("rは実装されていません。")
    else:
        print("移動軸に問題があります!")

    # 座標をファイルへ書き込む
    csv_write(file_name, dType.GetPose(api))

    # 1回動作指令を出す関数
    # def _OneAction(api, x=None, y=None, z=None, r=None, mode=dType.PTPMode.PTPMOVLXYZMode):
    """One step operation"""
Exemple #4
0
def _OneAction(api, pose, mode=dType.PTPMode.PTPMOVLXYZMode):
    """One step operation"""
    # if pose["x"] == None or y is None or z is None or r is None:
    current_pose = dType.GetPose(api)
    if pose["x"] is None:
        pose["x"] = current_pose[0]
    if pose["y"] is None:
        pose["y"] = current_pose[1]
    if pose["z"] is None:
        pose["z"] = current_pose[2]
    if pose["r"] is None:
        pose["r"] = current_pose[3]
    try:
        lastIndex = dType.SetPTPCmd(
            api, mode, pose["x"], pose["y"], pose["z"], pose["r"], isQueued=1
        )[0]
        __Act(api, lastIndex)
    except TimeoutError:
        return -1
    else:
        return 0
Exemple #5
0
    def GetPose_UpdateWindow(self) -> dict:
        """
        姿勢を取得し、ウインドウを更新する関数

        Return:
            pose (dict):
                Dobotの現在の姿勢
        """

        pose = dType.GetPose(self.api)  # 現在のDobotの位置と関節角度を取得
        pose = dict(zip(self.pose_key, pose))  # 辞書形式に変換

        self.Window["-JointPose1-"].update(str(pose["joint1Angle"]))
        self.Window["-JointPose2-"].update(str(pose["joint2Angle"]))
        self.Window["-JointPose3-"].update(str(pose["joint3Angle"]))
        self.Window["-JointPose4-"].update(str(pose["joint4Angle"]))
        self.Window["-CoordinatePose_X-"].update(str(pose["x"]))
        self.Window["-CoordinatePose_Y-"].update(str(pose["y"]))
        self.Window["-CoordinatePose_Z-"].update(str(pose["z"]))
        self.Window["-CoordinatePose_R-"].update(str(pose["r"]))

        return pose