pycram.object_descriptors.urdf
==============================

.. py:module:: pycram.object_descriptors.urdf


Classes
-------

.. autoapisummary::

   pycram.object_descriptors.urdf.LinkDescription
   pycram.object_descriptors.urdf.JointDescription
   pycram.object_descriptors.urdf.ObjectDescription


Module Contents
---------------

.. py:class:: LinkDescription(urdf_description: urdf_parser_py.urdf.Link)

   Bases: :py:obj:`pycram.description.LinkDescription`


   A class that represents a link description of an object.


   .. py:property:: geometry
      :type: typing_extensions.List[pycram.datastructures.dataclasses.VisualShape]


      :return: The geometry type of the URDF collision element of this link.



   .. py:property:: visual_geometry
      :type: typing_extensions.List[pycram.datastructures.dataclasses.VisualShape]


      :return: The geometry type of the URDF visual element of this link.



   .. py:method:: _get_visual_shape(urdf_geometry) -> typing_extensions.Union[pycram.datastructures.dataclasses.VisualShape, None]
      :staticmethod:


      :param urdf_geometry: The URDFGeometry for which the visual shape is returned.
      :return: the VisualShape of the given URDF geometry.



   .. py:property:: origin
      :type: typing_extensions.Optional[pycram.datastructures.pose.PoseStamped]


      The origin of this link

      :return: The origin of this link as a PoseStamped object.



   .. py:property:: name
      :type: str


      :return: the name of this entity.



   .. py:property:: collision
      :type: typing_extensions.Union[urdf_parser_py.urdf.Collision, typing_extensions.List[urdf_parser_py.urdf.Collision], None]



   .. py:property:: all_collisions
      :type: typing_extensions.List[urdf_parser_py.urdf.Collision]



.. py:class:: JointDescription(urdf_description: urdf_parser_py.urdf.Joint, is_virtual: typing_extensions.Optional[bool] = False)

   Bases: :py:obj:`pycram.description.JointDescription`


   A class that represents the description of a joint.


   .. py:attribute:: urdf_type_map


   .. py:attribute:: pycram_type_map


   .. py:property:: origin
      :type: pycram.datastructures.pose.PoseStamped


      :return: the origin of this entity.



   .. py:property:: name
      :type: str


      :return: the name of this entity.



   .. py:property:: has_limits
      :type: bool


      :return: True if the joint has limits, False otherwise.



   .. py:property:: type
      :type: pycram.datastructures.enums.JointType


      :return: The type of this joint.



   .. py:property:: axis
      :type: pycram.datastructures.pose.Point


      :return: The axis of this joint, for example the rotation axis for a revolute joint.



   .. py:property:: lower_limit
      :type: typing_extensions.Union[float, None]


      :return: The lower limit of this joint, or None if the joint has no limits.



   .. py:property:: upper_limit
      :type: typing_extensions.Union[float, None]


      :return: The upper limit of this joint, or None if the joint has no limits.



   .. py:property:: parent
      :type: str


      :return: The name of the parent link of this joint.



   .. py:property:: child
      :type: str


      :return: The name of the child link of this joint.



   .. py:property:: damping
      :type: float


      :return: The damping of this joint.



   .. py:property:: friction
      :type: float


      :return: The friction of this joint.



.. py:class:: ObjectDescription(path: typing_extensions.Optional[str] = None)

   Bases: :py:obj:`pycram.description.ObjectDescription`


   A class that represents an object description of an object.


   .. py:class:: Link(_id: int, link_description: LinkDescription, obj: pycram.world_concepts.world_object.Object, concept: typing_extensions.Type[pycrap.ontologies.Base] = pycrap.ontologies.Link, parse_name: bool = True)

      Bases: :py:obj:`pycram.description.ObjectDescription.Link`, :py:obj:`LinkDescription`


      A link of an Object in the World.



   .. py:class:: RootLink(obj: pycram.world_concepts.world_object.Object)

      Bases: :py:obj:`pycram.description.ObjectDescription.RootLink`, :py:obj:`Link`


      The root link of an Object in the World.
      This differs from the normal AbstractLink class in that the pose and the tf_frame is the same as that of the object.



   .. py:class:: Joint(_id: int, joint_description: JointDescription, obj: pycram.world_concepts.world_object.Object, is_virtual: typing_extensions.Optional[bool] = False, concept: typing_extensions.Type[pycrap.ontologies.Base] = pycrap.ontologies.Joint)

      Bases: :py:obj:`pycram.description.ObjectDescription.Joint`, :py:obj:`JointDescription`


      Represent a joint of an Object in the World.



   .. py:property:: child_map
      :type: typing_extensions.Dict[str, typing_extensions.List[typing_extensions.Tuple[str, str]]]


      :return: A dictionary mapping the name of a link to its children which are represented as a tuple of the child
          joint name and the link name.



   .. py:property:: parent_map
      :type: typing_extensions.Dict[str, typing_extensions.Tuple[str, str]]


      :return: A dictionary mapping the name of a link to its parent joint and link as a tuple.



   .. py:property:: link_map
      :type: typing_extensions.Dict[str, LinkDescription]


      :return: A dictionary mapping the name of a link to its description.



   .. py:property:: joint_map
      :type: typing_extensions.Dict[str, JointDescription]


      :return: A dictionary mapping the name of a joint to its description.



   .. py:method:: _init_joints_map() -> None


   .. py:method:: _init_links_map() -> None


   .. py:method:: add_joint(name: str, child: str, joint_type: pycram.datastructures.enums.JointType, axis: typing_extensions.Optional[pycram.datastructures.pose.Point] = None, parent: typing_extensions.Optional[str] = None, origin: typing_extensions.Optional[pycram.datastructures.pose.PoseStamped] = None, lower_limit: typing_extensions.Optional[float] = None, upper_limit: typing_extensions.Optional[float] = None, is_virtual: typing_extensions.Optional[bool] = False) -> None

      Add a joint to the object description, could be a virtual joint as well.
      For documentation of the parameters, see :meth:`pycram.description.ObjectDescription.add_joint`.



   .. py:method:: add_joint_from_parsed_description(description: urdf_parser_py.urdf.Joint) -> None

      Add a joint to the object description from a parsed URDF joint description.

      :param description: The parsed URDF joint description.



   .. py:method:: add_link_from_parsed_description(description: urdf_parser_py.urdf.Link) -> None

      Add a link to the object description from a parsed URDF link description.

      :param description: The parsed URDF link description.



   .. py:method:: merge_description(other: ObjectDescription, parent_link: typing_extensions.Optional[str] = None, child_link: typing_extensions.Optional[str] = None, joint_type: pycram.datastructures.enums.JointType = JointType.FIXED, axis: typing_extensions.Optional[pycram.datastructures.pose.Point] = None, lower_limit: typing_extensions.Optional[float] = None, upper_limit: typing_extensions.Optional[float] = None, child_pose_wrt_parent: typing_extensions.Optional[pycram.datastructures.pose.PoseStamped] = None, in_place: bool = False, new_description_file: typing_extensions.Optional[str] = None) -> typing_extensions.Union[ObjectDescription, typing_extensions.Self]

      Merge the description of this object with the description of the other object.

      :param other: The object description to merge with this one.
      :param parent_link: The name of the parent link of the joint connecting the two objects.
      :param child_link: The name of the child link of the joint connecting the two objects.
      :param joint_type: The type of the joint connecting the two objects.
      :param axis: The axis of the joint connecting the two objects.
      :param lower_limit: The lower limit of the joint connecting the two objects.
      :param upper_limit: The upper limit of the joint connecting the two objects.
      :param child_pose_wrt_parent: The pose of the child link with respect to the parent link.
      :param in_place: True if the merge should be done in place, False otherwise.
      :param new_description_file: If given, the new description will be saved to this file, otherwise the new
          description will be saved in place of the original file.
      :return: The merged object description, could be a new object description if in_place is False else self.



   .. py:method:: _init_description() -> None


   .. py:method:: load_description(path) -> urdf_parser_py.urdf.URDF

      Load the description from the file at the given path.

      :param path: The path to the source file, if only a filename is provided then the resources directories will be
       searched.



   .. py:method:: generate_from_mesh_file(path: str, name: str, save_path: str, color: typing_extensions.Optional[pycram.datastructures.dataclasses.Color] = Color(), scale: typing_extensions.Optional[float] = None) -> None

      Generate a URDf file with the given .obj or .stl file as mesh. In addition, use the given rgba_color to create a
       material tag in the URDF. The URDF file will be saved to the given save_path.

      :param path: The path to the mesh file.
      :param name: The name of the object.
      :param save_path: The path to save the URDF file to.
      :param color: The color of the object.
      :param scale: The scale of the mesh.



   .. py:method:: generate_from_description_file(path: str, save_path: str, make_mesh_paths_absolute: bool = True) -> None

      Generates a loadable URDF file from the given URDF file. The method will fix the attributes of some links,
      replace relative paths with absolute paths and fix the missing inertial tags. The generated URDF file will be
      saved to the given save_path.

      :param path: Path to the URDF file which should be processed.
      :param save_path: Path to where to save the processed URDF file.
      :param make_mesh_paths_absolute: If mesh paths should be made absolute. This is needed for PyBullet to load the URDF file.



   .. py:method:: generate_from_parameter_server(name: str, save_path: str) -> None

      Preprocess the description from the ROS parameter server and return the preprocessed description string.
      The preprocessed description will be saved at the given save_path.

      :param name: The name of the description on the parameter server.
      :param save_path: The path to save the preprocessed description file.



   .. py:property:: joints
      :type: typing_extensions.List[JointDescription]


      :return: A list of joints descriptions of this object.



   .. py:method:: _init_joints() -> None


   .. py:property:: links
      :type: typing_extensions.List[LinkDescription]


      :return: A list of link descriptions of this object.



   .. py:method:: _init_links() -> None


   .. py:method:: get_root() -> str

      :return: the name of the root link of this object.



   .. py:method:: get_tip() -> str

      :return: the name of the tip link of this object.
      :raises MultiplePossibleTipLinks: If there are multiple possible tip links.



   .. py:method:: get_chain(start_link_name: str, end_link_name: str, joints: typing_extensions.Optional[bool] = True, links: typing_extensions.Optional[bool] = True, fixed: typing_extensions.Optional[bool] = True) -> typing_extensions.List[str]

      :param start_link_name: The name of the start link of the chain.
      :param end_link_name: The name of the end link of the chain.
      :param joints: Whether to include joints in the chain.
      :param links: Whether to include links in the chain.
      :param fixed: Whether to include fixed joints in the chain.
      :return: the chain of links from 'start_link_name' to 'end_link_name'.



   .. py:method:: replace_relative_references_with_absolute_paths(urdf_string: str) -> str
      :staticmethod:


      Change paths for files in the URDF from ROS paths and file dir references to paths in the file system. Since
      World (PyBullet legacy) can't deal with ROS package paths.

      :param urdf_string: The name of the URDf on the parameter server
      :return: The URDF string with paths in the filesystem instead of ROS packages



   .. py:method:: make_mesh_paths_absolute(urdf_string: str, urdf_file_path: str) -> str
      :staticmethod:


      Convert all relative mesh paths in the URDF to absolute paths.

      :param urdf_string: The URDF description as string
      :param urdf_file_path: The path to the URDF file
      :returns: The new URDF description as string.



   .. py:method:: fix_missing_inertial(urdf_string: str) -> str
      :staticmethod:


      Insert inertial tags for every URDF link that has no inertia.
      This is used to prevent Legacy(PyBullet) from dumping warnings in the terminal

      :param urdf_string: The URDF description as string
      :returns: The new, corrected URDF description as string.



   .. py:method:: remove_error_tags(urdf_string: str) -> str
      :staticmethod:


      Remove all tags in the removing_tags list from the URDF since these tags are known to cause errors with the
      URDF_parser

      :param urdf_string: String of the URDF from which the tags should be removed
      :return: The URDF string with the tags removed



   .. py:method:: fix_link_attributes(urdf_string: str) -> str
      :staticmethod:


      Remove the attribute 'type' from links since this is not parsable by the URDF parser.

      :param urdf_string: The string of the URDF from which the attributes should be removed
      :return: The URDF string with the attributes removed



   .. py:method:: get_file_extension() -> str
      :staticmethod:


      :return: The file extension of the URDF file.



   .. py:property:: origin
      :type: pycram.datastructures.pose.PoseStamped


      :return: the origin of this entity.



   .. py:property:: name
      :type: str


      :return: the name of this entity.



