Ejemplo n.º 1
0
 def frame(self, value):
     if value is None:
         self._frame = Frame.worldXY()
     if 'euler_angles' in value:
         if 'point' in value:
             self._frame = Frame.from_euler_angles(
                                     radians(value['euler_angles']),
                                     value['point'])
         self._frame = Frame.from_euler_angles(
                                     radians(value['euler_angles']))
     else:
         point = value[0]
         xaxis = value[1]
         yaxis = value[2]
         self._frame = Frame(point, xaxis, yaxis)
Ejemplo n.º 2
0
    def from_urdf(cls, attributes, elements=None, text=None):
        """Create origin instance from an URDF element.

        Parameters
        ----------
        attributes : dict[str, Any]
            Attributes of the URDF element.
        elements: list[object], optional
            Children elements of the URDF element.
        text: str, optional
            Text content of the URDF element.

        Returns
        -------
        :class:`FrameProxy`
            Frame proxy instance.

        Examples
        --------
        >>> attributes = {'rpy': '0.0 1.57 0.0', 'xyz': '0.0 0.13 0.0'}
        >>> f = FrameProxy.from_urdf(attributes, [], None)
        >>> f
        Frame(Point(0.000, 0.130, 0.000), Vector(0.001, 0.000, -1.000), Vector(0.000, 1.000, 0.000))

        """
        xyz = _parse_floats(attributes.get('xyz', '0 0 0'))
        rpy = _parse_floats(attributes.get('rpy', '0 0 0'))
        return cls(
            Frame.from_euler_angles(rpy, static=True, axes='xyz', point=xyz))
Ejemplo n.º 3
0
    def __init__(self,
                 name,
                 type,
                 parent,
                 child,
                 origin=None,
                 axis=None,
                 calibration=None,
                 dynamics=None,
                 limit=None,
                 safety_controller=None,
                 mimic=None,
                 **kwargs):

        type_idx = type

        if isinstance(type_idx, str) and type_idx in Joint.SUPPORTED_TYPES:
            type_idx = Joint.SUPPORTED_TYPES.index(type_idx)

        if type_idx not in range(len(Joint.SUPPORTED_TYPES)):
            raise ValueError('Unsupported joint type: %s' % type)

        super(Joint, self).__init__()
        self.name = name
        self.type = type_idx
        self.parent = parent if isinstance(parent,
                                           ParentLink) else ParentLink(parent)
        self.child = child if isinstance(child,
                                         ChildLink) else ChildLink(child)
        self.origin = origin or Frame.from_euler_angles([0., 0., 0.])
        self.axis = axis or Axis()
        self.calibration = calibration
        self.dynamics = dynamics
        self.limit = limit
        self.safety_controller = safety_controller
        self.mimic = mimic
        self.attr = kwargs
        self.child_link = None
        self.position = 0
        # The following are world-relative frames representing the origin and the axis, which change with
        # the joint state, while `origin` and `axis` above are parent-relative and static.
        self.current_origin = self.origin.copy()
        self.current_axis = self.axis.copy()
Ejemplo n.º 4
0
def fixed_waam_setup():
    HERE = os.path.dirname(__file__)
    package_path = os.path.abspath(
        os.path.join(HERE, "..", "..", "data", "robots", "abb_fixed_waam"))
    urdf_filename = os.path.join(package_path, "urdf", "abb_fixed_waam.urdf")
    srdf_filename = os.path.join(package_path, "srdf", "abb_fixed_waam.srdf")

    model = RobotModel.from_urdf_file(urdf_filename)
    semantics = RobotSemantics.from_srdf_file(srdf_filename, model)

    tool_frame_robotA = Frame.from_euler_angles(
        [0.591366, -0.000922, 1.570177],
        static=True,
        axes='xyz',
        point=[-0.002241, -0.000202, 0.505922])
    tool_mesh_robotA = Mesh.from_obj(
        os.path.join(package_path, "meshes", "collision", "waam_tool.obj"))
    robotA_tool = Tool(tool_mesh_robotA,
                       tool_frame_robotA,
                       collision=tool_mesh_robotA)
    return urdf_filename, semantics, robotA_tool
"""There are several ways to construct a `Frame`.
"""
from compas.geometry import Point
from compas.geometry import Vector
from compas.geometry import Frame
from compas.geometry import Plane

# Frame autocorrects axes to be orthonormal
F = Frame(Point(1, 0, 0), Vector(-0.45, 0.1, 0.3), Vector(1, 0, 0))

F = Frame([1, 0, 0], [-0.45, 0.1, 0.3], [1, 0, 0])

F = Frame.from_points([1, 1, 1], [2, 3, 6], [6, 3, 0])
F = Frame.from_plane(Plane([0, 0, 0], [0.5, 0.2, 0.1]))
F = Frame.from_euler_angles([0.5, 1., 0.2])
F = Frame.worldXY()