Exemple #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)
Exemple #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
Exemple #3
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)
Exemple #4
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
Exemple #5
0
 def speedl_tool(self, velocities, acc, min_time):
     """
     move at given velocities in tool csys until minimum min_time seconds
     """
     pose = self.get_pose()
     v = pose.orient * m3d.Vector(velocities[:3])
     w = pose.orient * m3d.Vector(velocities[3:])
     URRobot.speedl(self, np.concatenate((v.array, w.array)), acc, min_time)
Exemple #6
0
 def speedl_tool(self, velocities, acc, min_time):
     """
     move at given velocities in tool csys until minimum min_time seconds
     """
     pose = self.get_pose()
     v = pose.orient * m3d.Vector(velocities[:3])
     w = pose.orient * m3d.Vector(velocities[3:])
     URRobot.speedl(self, np.concatenate((v.array, w.array)), acc, min_time)
Exemple #7
0
 def speedx(self, command, velocities, acc, min_time):
     """
     send command to robot formated like speedl or speedj
     move at given velocities until minimum min_time seconds
     """
     v = self.csys.orient * m3d.Vector(velocities[:3])
     w = self.csys.orient * m3d.Vector(velocities[3:])
     URRobot.speedx(self, command, np.concatenate((v.array, w.array)), acc, min_time)
Exemple #8
0
 def speedx(self, command, velocities, acc, min_time):
     """
     send command to robot formated like speedl or speedj
     move at given velocities until minimum min_time seconds
     """
     v = self.csys.orient * m3d.Vector(velocities[:3])
     w = self.csys.orient * m3d.Vector(velocities[3:])
     URRobot.speedx(self, command, np.concatenate((v.array, w.array)), acc,
                    min_time)
Exemple #9
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)
Exemple #10
0
 def set_pose(self,
              trans,
              acc=0.01,
              vel=0.01,
              wait=True,
              command="movel",
              threshold=None,
              radius=0):
     """
     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,
                          radius=radius)
     if pose is not None:
         return self.csys.inverse * m3d.Transform(pose)
Exemple #11
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
Exemple #12
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
Exemple #13
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)
Exemple #14
0
 def new_csys_from_xpy(self):
     """
     Return new coordinate system from three points: X, Origin, Y
     based on math3d: Transform.new_from_xyp
     """
     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)
     p0 = m3d.Vector(pose[:3])
     input("Move to second point and click Enter")
     pose = URRobot.getl(self)
     p1 = m3d.Vector(pose[:3])
     input("Move to second point and click Enter")
     pose = URRobot.getl(self)
     p2 = m3d.Vector(pose[:3])
     return m3d.Transform.new_from_xyp(p1 - p0, p2 - p0, p0)
Exemple #15
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)
Exemple #16
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)
Exemple #17
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)
Exemple #18
0
 def new_csys_from_xpy(self):
     """
     Return new coordinate system from three points: X, Origin, Y
     based on math3d: Transform.new_from_xyp
     """
     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)
     p0 = m3d.Vector(pose[:3])
     input("Move to second point and click Enter")
     pose = URRobot.getl(self)
     p1 = m3d.Vector(pose[:3])
     input("Move to second point and click Enter")
     pose = URRobot.getl(self)
     p2 = m3d.Vector(pose[:3])
     return m3d.Transform.new_from_xyp(p1 - p0, p2 - p0, p0)
Exemple #19
0
 def __init__(self, host, use_rt=False):
     URRobot.__init__(self, host, use_rt)
     self.csys = m3d.Transform()
Exemple #20
0
 def set_gravity(self, vector):
     if isinstance(vector, m3d.Vector):
         vector = vector.list
     return URRobot.set_gravity(self, vector)
Exemple #21
0
 def __init__(self, host, use_rt=False):
     URRobot.__init__(self, host, use_rt)
     self.csys = m3d.Transform()
 def __init__(self, host, use_rt=False, use_simulation=False):
     URRobot.__init__(self, host, use_rt, use_simulation)
     self.csys = m3d.Transform()
Exemple #23
0
 def __init__(self, host, timeout=0.5):
     URRobot.__init__(self, host, timeout)
     self.csys = m3d.Transform()
Exemple #24
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)
Exemple #25
0
 def set_gravity(self, vector):
     if isinstance(vector, m3d.Vector):
         vector = vector.list
     return URRobot.set_gravity(self, vector)
Exemple #26
0
 def __init__(self, host, use_rt=False, timeout=0.5):
     URRobot.__init__(self, host, use_rt, timeout=timeout)
     self.csys = m3d.Transform()
Exemple #27
0
 def __init__(self, host, use_rt=False, urFirm=None):
     URRobot.__init__(self, host, use_rt, urFirm)
     self.csys = m3d.Transform()
Exemple #28
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)