Exemplo n.º 1
0
 def set_tcp(self, tcp):
     """
     set robot flange to tool tip transformation
     """
     if isinstance(tcp, m3d.Transform):
         tcp = tcp.pose_vector
     URRobot.set_tcp(self, tcp)
Exemplo n.º 2
0
    def new_csys_from_xpy(self):
        """
        Restores and returns new coordinate system calculated from three points: X, Origin, Y

        based on math3d: Transform.new_from_xyp
        """
        # Set coord. sys. to 0
        self.csys = m3d.Transform()

        print(
            "A new coordinate system will be defined from the next three points"
        )
        print("Firs point is X, second Origin, third Y")
        print(
            "Set it as a new reference by calling myrobot.set_csys(new_csys)")
        input("Move to first point and click Enter")
        # we do not use get_pose so we avoid rounding values
        pose = URRobot.getl(self)
        print("Introduced point defining X: {}".format(pose[:3]))
        px = m3d.Vector(pose[:3])
        input("Move to second point and click Enter")
        pose = URRobot.getl(self)
        print("Introduced point defining Origo: {}".format(pose[:3]))
        p0 = m3d.Vector(pose[:3])
        input("Move to third point and click Enter")
        pose = URRobot.getl(self)
        print("Introduced point defining Y: {}".format(pose[:3]))
        py = m3d.Vector(pose[:3])

        new_csys = m3d.Transform.new_from_xyp(px - p0, py - p0, p0)
        self.set_csys(new_csys)

        return new_csys
Exemplo n.º 3
0
 def movexs(self,
            command,
            pose_list,
            acc=0.01,
            vel=0.01,
            radius=0.01,
            wait=True,
            threshold=None):
     """
     Concatenate several movex commands and applies a blending radius
     pose_list is a list of pose.
     This method is usefull since any new command from python
     to robot make the robot stop
     """
     new_poses = []
     for pose in pose_list:
         t = self.csys * m3d.Transform(pose)
         pose = t.pose_vector
         new_poses.append(pose)
     return URRobot.movexs(self,
                           command,
                           new_poses,
                           acc,
                           vel,
                           radius,
                           wait=wait,
                           threshold=threshold)
Exemplo n.º 4
0
 def get_pose(self, wait=False, _log=True):
     """
     get current transform from base to to tcp
     """
     pose = URRobot.getl(self, wait, _log)
     trans = self.csys.inverse * m3d.Transform(pose)
     if _log:
         self.logger.debug("Returning pose to user: %s", trans.pose_vector)
     return trans
Exemplo n.º 5
0
 def movec(self,
           pose_via,
           pose_to,
           acc=0.01,
           vel=0.01,
           wait=True,
           threshold=None):
     """
     Move Circular: Move to position (circular in tool-space)
     see UR documentation
     """
     pose_via = self.csys * m3d.Transform(pose_via)
     pose_to = self.csys * m3d.Transform(pose_to)
     pose = URRobot.movec(self,
                          pose_via.pose_vector,
                          pose_to.pose_vector,
                          acc=acc,
                          vel=vel,
                          wait=wait,
                          threshold=threshold)
     if pose is not None:
         return self.csys.inverse * m3d.Transform(pose)
Exemplo n.º 6
0
 def set_pose(self,
              trans,
              acc=0.01,
              vel=0.01,
              wait=True,
              command="movel",
              threshold=None):
     """
     move tcp to point and orientation defined by a transformation
     UR robots have several move commands, by default movel is used but it can be changed
     using the command argument
     """
     self.logger.debug("Setting pose to %s", trans.pose_vector)
     t = self.csys * trans
     pose = URRobot.movex(self,
                          command,
                          t.pose_vector,
                          acc=acc,
                          vel=vel,
                          wait=wait,
                          threshold=threshold)
     if pose is not None:
         return self.csys.inverse * m3d.Transform(pose)
Exemplo n.º 7
0
 def set_gravity(self, vector):
     if isinstance(vector, m3d.Vector):
         vector = vector.list
     return URRobot.set_gravity(self, vector)
Exemplo n.º 8
0
 def _get_lin_dist(self, target):
     pose = URRobot.getl(self, wait=True)
     target = m3d.Transform(target)
     pose = m3d.Transform(pose)
     return pose.dist(target)
Exemplo n.º 9
0
 def __init__(self, host, use_rt=False):
     URRobot.__init__(self, host, use_rt)
     self.csys = m3d.Transform()