pycram.object_descriptors.generic
=================================

.. py:module:: pycram.object_descriptors.generic


Classes
-------

.. autoapisummary::

   pycram.object_descriptors.generic.NamedBoxVisualShape
   pycram.object_descriptors.generic.LinkDescription
   pycram.object_descriptors.generic.JointDescription
   pycram.object_descriptors.generic.ObjectDescription


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

.. py:class:: NamedBoxVisualShape(name: str, color: pycram.datastructures.dataclasses.Color, visual_frame_position: typing_extensions.List[float], half_extents: typing_extensions.List[float])

   Bases: :py:obj:`pycram.datastructures.dataclasses.BoxVisualShape`


   .. py:attribute:: _name
      :type:  str


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



.. py:class:: LinkDescription(name: str, visual_frame_position: typing_extensions.List[float], half_extents: typing_extensions.List[float], color: pycram.datastructures.dataclasses.Color = Color())

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


   A link description of an object.


   .. py:property:: geometry
      :type: typing_extensions.Union[pycram.datastructures.dataclasses.VisualShape, None]


      The geometry type of the collision element of this link.



   .. 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:: color
      :type: pycram.datastructures.dataclasses.Color



.. py:class:: JointDescription(parsed_joint_description: typing_extensions.Optional[typing_extensions.Any] = None, is_virtual: bool = False)

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


   A class that represents the description of a joint.


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

      :abstractmethod:


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



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

      :abstractmethod:


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



   .. 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:: has_limits
      :type: bool


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



   .. 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_link_name
      :type: str

      :abstractmethod:



   .. py:property:: child_link_name
      :type: str

      :abstractmethod:



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

      :abstractmethod:


      :return: the origin of this entity.



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

      :abstractmethod:


      :return: the name of this entity.



.. py:class:: ObjectDescription(*args, **kwargs)

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


   A generic description of an object in the environment. This description can be applied to any object.
   The current use case involves perceiving objects using RoboKudo and spawning them with specified size and color.


   .. 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:attribute:: _links


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

      Merge the current object description with another object description by merging their bounding boxes and
      creating a URDF description with the new merged bounding box/ mesh.

      :param other: The other object description to merge with.
      :param child_pose_wrt_parent: The pose of the child object wrt the parent object.
      :param new_description_file: The path to save the new description file.
      :return: The new object description.



   .. py:method:: merge_using_urdf(other: ObjectDescription, child_pose_wrt_parent: Optional[pycram.datastructures.pose.PoseStamped] = None, new_description_file: Optional[str] = None) -> typing_extensions.Union[ObjectDescription, typing_extensions.Self]

      Merge the current object description with another object description by creating a URDF description for both
      objects and merging them.

      :param other: The other object description to merge with.
      :param child_pose_wrt_parent: The pose of the child object wrt the parent object.
      :param new_description_file: The path to save the new description file.
      :return: The new object description.



   .. py:method:: create_urdf_from_mesh(mesh: Optional[trimesh.Trimesh] = None, mesh_file_path: Optional[str] = None, path: Optional[str] = None) -> pycram.object_descriptors.urdf.ObjectDescription

      Create a URDF description from the mesh and the current object description.

      :param mesh: The mesh to create the URDF description from.
      :param mesh_file_path: The path to the mesh file.
      :param path: The path to save the URDF description.
      :return: The URDF object description.



   .. py:method:: get_mesh() -> trimesh.Trimesh

      Get the mesh of the object.



   .. py:method:: load_description(path: str) -> typing_extensions.Any

      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: pycram.datastructures.dataclasses.Color) -> str
      :classmethod:

      :abstractmethod:


      Generate a description file from one of the mesh types defined in the mesh_extensions and
      return the path of the generated file. The generated file will be saved at the given save_path.

      :param path: The path to the .obj file.
      :param name: The name of the object.
      :param save_path: The path to save the generated description file.
      :param color: The color of the object.



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

      :abstractmethod:


      Preprocess the given file and return the preprocessed description string. The preprocessed description will be
      saved at the given save_path.

      :param path: The path of the file to preprocess.
      :param save_path: The path to save the preprocessed description file.
      :param make_mesh_paths_absolute: Whether to make the mesh paths absolute.



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

      :abstractmethod:


      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:: parent_map
      :type: typing_extensions.Dict[str, 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:property:: child_map
      :type: typing_extensions.Dict[str, typing_extensions.List[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:method:: add_joint(name: str, child: str, joint_type: pycram.datastructures.enums.JointType, axis: pycram.datastructures.pose.Point, parent: Optional[str] = None, origin: Optional[pycram.datastructures.pose.PoseStamped] = None, lower_limit: Optional[float] = None, upper_limit: Optional[float] = None, is_virtual: Optional[bool] = False) -> None

      Add a joint to this object.

      :param name: The name of the joint.
      :param child: The name of the child link.
      :param joint_type: The type of the joint.
      :param axis: The axis of the joint.
      :param parent: The name of the parent link.
      :param origin: The origin of the joint.
      :param lower_limit: The lower limit of the joint.
      :param upper_limit: The upper limit of the joint.
      :param is_virtual: True if the joint is virtual, False otherwise.



   .. py:property:: shape_data
      :type: typing_extensions.List[float]



   .. py:property:: color
      :type: pycram.datastructures.dataclasses.Color



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


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



   .. py:method:: get_link_by_name(link_name: str) -> LinkDescription

      :return: The link description with the given name.



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


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



   .. py:method:: get_joint_by_name(joint_name: str) -> JointDescription

      :return: The joint description with the given name.



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

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



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


      :return: the chain of links from 'start_link_name' to 'end_link_name'.



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

      :abstractmethod:


      :return: The file extension of the description 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.



