timor.Geometry ============== .. py:module:: timor.Geometry Classes ------- .. autoapisummary:: timor.Geometry.Box timor.Geometry.ComposedGeometry timor.Geometry.Cylinder timor.Geometry.EmptyGeometry timor.Geometry.Geometry timor.Geometry.GeometryType timor.Geometry.HppfclEnumMeta timor.Geometry.Mesh timor.Geometry.Sphere Functions --------- .. autoapisummary:: timor.Geometry._geometry_type2class Module Contents --------------- .. py:class:: Box(parameters, pose = Transformation.neutral(), hppfcl_representation = None) .. autoapi-inheritance-diagram:: timor.Geometry.Box :parts: 1 :private-bases: A simple geometry with a box extending in x, y and z direction. The geometry class is the default way to describe a volume in space. :param parameters: Class-specific parameters defining the volume of the geometry. Will be unpacked in child classes :param pose: Transformation in world coordinates of this geometry :param hppfcl_representation: A hppfcl collision geometry representing this geometry in collision checks. If not provided, will be created. If provided, there will be no checks whether it fits the given parameters! .. py:method:: __deepcopy__(memodict={}) Must be implemented for Geometries, as hppfcl does not natively support it. .. py:method:: __eq__(other) Compares two Geometry instances based on their type, parameters and placement. .. py:method:: __getstate__() Return objects which will be pickled and saved. .. py:method:: __hash__() Hashes the Geometry instance based on its type, parameters and placement. .. py:method:: __setstate__(state) Take object from parameter and use it to retrieve class state. .. py:attribute:: __slots__ :value: () .. py:method:: _deduce_package_dir(filepath, content) :staticmethod: Logic for deducing the package directory if the JSONable object is loaded from a file. :param filepath: The path to the file. :param content: The content of the file parsed into a dictionary. :note: This method can be overridden by subclasses to provide custom package directory resolution; e.g. Task.py. .. py:method:: _make_collision_geometry() A hppfcl box is centered in the symmetry axes of the box defined by width, height, depth .. py:property:: as_hppfcl_collision_object :type: Tuple[hppfcl.hppfcl.CollisionObject, Ellipsis] Creates hppfcl CollisionObject(s) at the current pose of self. .. py:property:: collision_data :type: Tuple[Tuple[numpy.ndarray, hppfcl.hppfcl.CollisionGeometry], Ellipsis] Returns a tuple of tuples: (placement_as_np, geometry) needed to perform collision checks with hppfcl .. py:property:: enclosing_volume :type: timor.Volume.BoxVolume Returns a box volume instance. .. py:method:: export_to_trimesh() Returns a trimesh box .. py:method:: from_hppfcl(fcl) :classmethod: Wraps a hppfcl Box in a Box instance. .. py:method:: from_json_data(d, package_dir = None, *args, **kwargs) :classmethod: Takes a serialized geometry specification and returns the according Geometry instance. :param d: A serialized geometry :param package_dir: The top directory to which the mesh file paths are relative to. Necessary for meshes (only). .. py:method:: from_json_file(filepath, *args, **kwargs) :classmethod: Factory method to load a class instance from a json file. :param filepath: The path to the json file. :param args: Additional arguments to pass to the from_json_data factory method of the specific class. :param kwargs: Additional arguments to pass to the from_json_data factory method of the specific class. .. py:method:: from_json_string(description, package_dir = None) :classmethod: Takes a serialized geometry specification and returns the according Geometry instance. :param description: A serialized geometry :param package_dir: The top directory to which the mesh file paths are relative to. Necessary for meshes (only). .. py:method:: from_pin_geometry(geo) :classmethod: A helper function that transforms a generic pinocchio GeometryObject to an according Geometry instance. :param geo: The pinocchio GeometryObject :return: An instance of the according Obstacle class, based on the kind of collision object handed over. .. py:attribute:: hppfcl_representation :type: hppfcl.hppfcl.CollisionGeometry .. py:property:: measure_volume :type: float Returns the actual scalar volume. .. py:attribute:: parameter_names :type: Tuple[str, str, str] :value: ('x', 'y', 'z') .. py:property:: parameters :type: Dict[str, float] Box parameters are fully described by x, y and z, each one being a float: {'x': f, 'y': f, 'z': f} .. py:attribute:: placement :type: timor.utilities.transformation.Transformation .. py:property:: serialized :type: List[Dict[str, any]] Creates a serialization of a Geometry that can be stored as json .. py:method:: to_json_data() The json-compatible serialization. .. py:method:: to_json_file(save_at, *args, **kwargs) Writes the instance to a json file. :param save_at: File location or folder to write the class to. .. py:method:: to_json_string() Returns a json string representation of this geometry. .. py:attribute:: type :type: GeometryType .. py:property:: urdf_properties :type: Tuple[str, Dict[str, List[float]]] A box in URDF is described by [x, y, z] .. py:property:: viz_object :type: Tuple[meshcat.geometry.Geometry, timor.utilities.transformation.Transformation] Returns a meshcat box .. py:property:: x :type: float Keep access to these attributes private .. py:property:: y :type: float Keep access to these attributes private .. py:property:: z :type: float Keep access to these attributes private .. py:class:: ComposedGeometry(geometries) .. autoapi-inheritance-diagram:: timor.Geometry.ComposedGeometry :parts: 1 :private-bases: A composed geometry is a collection of geometries that are combined in one instance. Composed geometries are fundamentally different from basic geometries. They are not loaded from a urdf or a single description but rather wrappers around a set of geometries. :param geometries: An iterable of geometries that are combined in this composed geometry. .. py:method:: __deepcopy__(memodict={}) Must be implemented for Geometries, as hppfcl does not natively support it. .. py:method:: __eq__(other) Equality is defined as having the same composing geometries. .. py:method:: __getstate__() Return objects which will be pickled and saved. .. py:method:: __hash__() Hash is defined as the hash of the composing geometries. .. py:method:: __setstate__(state) Take object from parameter and use it to retrieve class state. .. py:attribute:: __slots__ :value: () .. py:attribute:: _composing_geometries :type: List[Geometry] .. py:method:: _deduce_package_dir(filepath, content) :staticmethod: Logic for deducing the package directory if the JSONable object is loaded from a file. :param filepath: The path to the file. :param content: The content of the file parsed into a dictionary. :note: This method can be overridden by subclasses to provide custom package directory resolution; e.g. Task.py. .. py:method:: _make_collision_geometry() :abstractmethod: This method is usually only called in the init, which is overwritten for this class. .. py:property:: as_hppfcl_collision_object :type: Tuple[hppfcl.hppfcl.CollisionObject, Ellipsis] Creates hppfcl CollisionObjects at the current placement of self. .. py:property:: collision_data :type: Tuple[Tuple[numpy.ndarray, hppfcl.hppfcl.CollisionGeometry], Ellipsis] Composed Geometries are the only ones with more than one element in the collision data .. py:attribute:: collision_geometry :value: None .. py:property:: composing_geometries :type: Tuple[Geometry] This attribute should be read-only, therefore the leading underscore and the return as tuple. .. py:property:: enclosing_volume For now, composed geometries do not have a volume. .. py:method:: export_to_trimesh() Returns a trimesh representation of this geometry. .. py:method:: from_hppfcl(fcl) :classmethod: :abstractmethod: hppfcl does not know the concept of composed geometries. .. py:method:: from_json_data(d, package_dir = None, *args, **kwargs) :classmethod: Takes a serialized geometry specification and returns the according Geometry instance. :param d: A serialized geometry :param package_dir: The top directory to which the mesh file paths are relative to. Necessary for meshes (only). .. py:method:: from_json_file(filepath, *args, **kwargs) :classmethod: Factory method to load a class instance from a json file. :param filepath: The path to the json file. :param args: Additional arguments to pass to the from_json_data factory method of the specific class. :param kwargs: Additional arguments to pass to the from_json_data factory method of the specific class. .. py:method:: from_json_string(description, package_dir = None) :classmethod: Takes a serialized geometry specification and returns the according Geometry instance. :param description: A serialized geometry :param package_dir: The top directory to which the mesh file paths are relative to. Necessary for meshes (only). .. py:method:: from_pin_geometry(geo) :classmethod: A helper function that transforms a generic pinocchio GeometryObject to an according Geometry instance. :param geo: The pinocchio GeometryObject :return: An instance of the according Obstacle class, based on the kind of collision object handed over. .. py:attribute:: hppfcl_representation :type: hppfcl.hppfcl.CollisionGeometry .. py:property:: measure_volume :type: float The scalar volume of a composed geometry is the sum of the volumes of the composing geometries. .. py:property:: parameters :type: Dict[str, Union[float, str]] :abstractmethod: This class cannot be instantiated from parameters, so this attribute is also not necessary. .. py:attribute:: placement :type: timor.utilities.transformation.Transformation .. py:property:: serialized :type: List[Dict[str, any]] Creates a json-compliant dictionary of a Geometry .. py:method:: to_json_data() The json-compatible serialization. .. py:method:: to_json_file(save_at, *args, **kwargs) Writes the instance to a json file. :param save_at: File location or folder to write the class to. .. py:method:: to_json_string() Returns a json string representation of this geometry. .. py:attribute:: type :type: GeometryType .. py:property:: urdf_properties :type: Tuple[str, Dict[str, Union[float, numpy.ndarray]]] :abstractmethod: urdf does not know the concept of composed geometries for collisions. .. py:property:: viz_object :type: Tuple[meshcat.geometry.Geometry, timor.utilities.transformation.Transformation] :abstractmethod: meshcat geometries can only represent a single geometry, so this method is not implemented. .. py:class:: Cylinder(parameters, pose = Transformation.neutral(), hppfcl_representation = None) .. autoapi-inheritance-diagram:: timor.Geometry.Cylinder :parts: 1 :private-bases: A simple geometry with a cylinder extending in x-y plane (r) and z direction. The geometry class is the default way to describe a volume in space. :param parameters: Class-specific parameters defining the volume of the geometry. Will be unpacked in child classes :param pose: Transformation in world coordinates of this geometry :param hppfcl_representation: A hppfcl collision geometry representing this geometry in collision checks. If not provided, will be created. If provided, there will be no checks whether it fits the given parameters! .. py:method:: __deepcopy__(memodict={}) Must be implemented for Geometries, as hppfcl does not natively support it. .. py:method:: __eq__(other) Compares two Geometry instances based on their type, parameters and placement. .. py:method:: __getstate__() Return objects which will be pickled and saved. .. py:method:: __hash__() Hashes the Geometry instance based on its type, parameters and placement. .. py:method:: __setstate__(state) Take object from parameter and use it to retrieve class state. .. py:attribute:: __slots__ :value: () .. py:method:: _deduce_package_dir(filepath, content) :staticmethod: Logic for deducing the package directory if the JSONable object is loaded from a file. :param filepath: The path to the file. :param content: The content of the file parsed into a dictionary. :note: This method can be overridden by subclasses to provide custom package directory resolution; e.g. Task.py. .. py:method:: _make_collision_geometry() A hppfcl cylinder is centered in the symmetry axes of the cylinder defined by radius and height. .. py:property:: as_hppfcl_collision_object :type: Tuple[hppfcl.hppfcl.CollisionObject, Ellipsis] Creates hppfcl CollisionObject(s) at the current pose of self. .. py:property:: collision_data :type: Tuple[Tuple[numpy.ndarray, hppfcl.hppfcl.CollisionGeometry], Ellipsis] Returns a tuple of tuples: (placement_as_np, geometry) needed to perform collision checks with hppfcl .. py:property:: enclosing_volume :type: timor.Volume.CylinderVolume Returns a cylinder volume instance. .. py:method:: export_to_trimesh() Returns a trimesh cylinder .. py:method:: from_hppfcl(fcl) :classmethod: Wraps a hppfcl Cylinder in a Cylinder instance. .. py:method:: from_json_data(d, package_dir = None, *args, **kwargs) :classmethod: Takes a serialized geometry specification and returns the according Geometry instance. :param d: A serialized geometry :param package_dir: The top directory to which the mesh file paths are relative to. Necessary for meshes (only). .. py:method:: from_json_file(filepath, *args, **kwargs) :classmethod: Factory method to load a class instance from a json file. :param filepath: The path to the json file. :param args: Additional arguments to pass to the from_json_data factory method of the specific class. :param kwargs: Additional arguments to pass to the from_json_data factory method of the specific class. .. py:method:: from_json_string(description, package_dir = None) :classmethod: Takes a serialized geometry specification and returns the according Geometry instance. :param description: A serialized geometry :param package_dir: The top directory to which the mesh file paths are relative to. Necessary for meshes (only). .. py:method:: from_pin_geometry(geo) :classmethod: A helper function that transforms a generic pinocchio GeometryObject to an according Geometry instance. :param geo: The pinocchio GeometryObject :return: An instance of the according Obstacle class, based on the kind of collision object handed over. .. py:attribute:: hppfcl_representation :type: hppfcl.hppfcl.CollisionGeometry .. py:property:: measure_volume :type: float Returns the actual scalar volume. .. py:attribute:: parameter_names :type: Tuple[str, str] :value: ('r', 'z') .. py:property:: parameters :type: Dict[str, float] Cylinder parameters are fully described by r and z: {'r': float, 'z': float} .. py:attribute:: placement :type: timor.utilities.transformation.Transformation .. py:property:: r :type: float Keep access to these attributes private .. py:property:: serialized :type: List[Dict[str, any]] Creates a serialization of a Geometry that can be stored as json .. py:method:: to_json_data() The json-compatible serialization. .. py:method:: to_json_file(save_at, *args, **kwargs) Writes the instance to a json file. :param save_at: File location or folder to write the class to. .. py:method:: to_json_string() Returns a json string representation of this geometry. .. py:attribute:: type :type: GeometryType .. py:property:: urdf_properties :type: Tuple[str, Dict[str, float]] A cylinder is specified with a radius and an extension in z-direction with origin in the symmetry axes .. py:property:: viz_object :type: Tuple[meshcat.geometry.Geometry, timor.utilities.transformation.Transformation] The meshcat cylinder is y-aligned while we expect it to be z-aligned .. py:property:: z :type: float Keep access to these attributes private .. py:class:: EmptyGeometry(parameters = None, pose = Transformation.neutral(), hppfcl_representation = None) .. autoapi-inheritance-diagram:: timor.Geometry.EmptyGeometry :parts: 1 :private-bases: This is a dummy geometry to being able to prevent setting a geometry to None. For an empty geometry, the parameters are not used. .. py:method:: __deepcopy__(memodict={}) Must be implemented for Geometries, as hppfcl does not natively support it. .. py:method:: __eq__(other) Empty geometries are equal to other empty geometries. .. py:method:: __getstate__() Return objects which will be pickled and saved. .. py:method:: __hash__() Empty geometries are equal to other empty geometries. .. py:method:: __setstate__(state) Take object from parameter and use it to retrieve class state. .. py:attribute:: __slots__ :value: () .. py:method:: _deduce_package_dir(filepath, content) :staticmethod: Logic for deducing the package directory if the JSONable object is loaded from a file. :param filepath: The path to the file. :param content: The content of the file parsed into a dictionary. :note: This method can be overridden by subclasses to provide custom package directory resolution; e.g. Task.py. .. py:method:: _make_collision_geometry() No Geometry, no collision object. .. py:property:: as_hppfcl_collision_object :type: Tuple[hppfcl.hppfcl.CollisionObject, Ellipsis] An empty geometry does not have a collision object. .. py:property:: collision_data :type: Tuple[Tuple[numpy.ndarray, hppfcl.hppfcl.CollisionGeometry], Ellipsis] No Geometry, no collision object. .. py:property:: enclosing_volume No need to calculate volume for empty geometry. .. py:method:: export_to_trimesh() Returns an empty trimesh as the representation of this geometry. .. py:method:: from_hppfcl(fcl) :classmethod: :abstractmethod: This method is not implemented as it is not necessary. .. py:method:: from_json_data(d, package_dir = None, *args, **kwargs) :classmethod: Takes a serialized geometry specification and returns the according Geometry instance. :param d: A serialized geometry :param package_dir: The top directory to which the mesh file paths are relative to. Necessary for meshes (only). .. py:method:: from_json_file(filepath, *args, **kwargs) :classmethod: Factory method to load a class instance from a json file. :param filepath: The path to the json file. :param args: Additional arguments to pass to the from_json_data factory method of the specific class. :param kwargs: Additional arguments to pass to the from_json_data factory method of the specific class. .. py:method:: from_json_string(description, package_dir = None) :classmethod: Takes a serialized geometry specification and returns the according Geometry instance. :param description: A serialized geometry :param package_dir: The top directory to which the mesh file paths are relative to. Necessary for meshes (only). .. py:method:: from_pin_geometry(geo) :classmethod: A helper function that transforms a generic pinocchio GeometryObject to an according Geometry instance. :param geo: The pinocchio GeometryObject :return: An instance of the according Obstacle class, based on the kind of collision object handed over. .. py:attribute:: hppfcl_representation :type: hppfcl.hppfcl.CollisionGeometry .. py:property:: measure_volume :type: float No Geometry, no volume. .. py:property:: parameters :type: Dict[str, Union[float, str]] No Geometry, no parameters. .. py:attribute:: placement :type: timor.utilities.transformation.Transformation .. py:property:: serialized :type: List[Dict[str, any]] Creates a serialization of a Geometry that can be stored as json .. py:method:: to_json_data() The json-compatible serialization. .. py:method:: to_json_file(save_at, *args, **kwargs) Writes the instance to a json file. :param save_at: File location or folder to write the class to. .. py:method:: to_json_string() Returns a json string representation of this geometry. .. py:attribute:: type :type: GeometryType .. py:property:: urdf_properties :type: Tuple[str, Dict[str, Union[float, numpy.ndarray]]] :abstractmethod: Omit this object when serializing. .. py:property:: viz_object :type: Tuple[meshcat.geometry.Geometry, timor.utilities.transformation.Transformation] :abstractmethod: Omit this object when serializing. .. py:class:: Geometry(parameters, pose = Transformation.neutral(), hppfcl_representation = None) .. autoapi-inheritance-diagram:: timor.Geometry.Geometry :parts: 1 :private-bases: A class describing geometries. A geometry is defined by a type (see GeometryType), an expansion (defined by custom parameters) and a placement, defining its spatial position and orientation. The geometry class is the default way to describe a volume in space. :param parameters: Class-specific parameters defining the volume of the geometry. Will be unpacked in child classes :param pose: Transformation in world coordinates of this geometry :param hppfcl_representation: A hppfcl collision geometry representing this geometry in collision checks. If not provided, will be created. If provided, there will be no checks whether it fits the given parameters! .. py:method:: __deepcopy__(memodict={}) Must be implemented for Geometries, as hppfcl does not natively support it. .. py:method:: __eq__(other) Compares two Geometry instances based on their type, parameters and placement. .. py:method:: __getstate__() Return objects which will be pickled and saved. .. py:method:: __hash__() Hashes the Geometry instance based on its type, parameters and placement. .. py:method:: __setstate__(state) Take object from parameter and use it to retrieve class state. .. py:attribute:: __slots__ :value: () .. py:method:: _deduce_package_dir(filepath, content) :staticmethod: Logic for deducing the package directory if the JSONable object is loaded from a file. :param filepath: The path to the file. :param content: The content of the file parsed into a dictionary. :note: This method can be overridden by subclasses to provide custom package directory resolution; e.g. Task.py. .. py:method:: _make_collision_geometry() :abstractmethod: Creates a hppfcl collision object aligned with the parameters of the Geometry .. py:property:: as_hppfcl_collision_object :type: Tuple[hppfcl.hppfcl.CollisionObject, Ellipsis] Creates hppfcl CollisionObject(s) at the current pose of self. .. py:property:: collision_data :type: Tuple[Tuple[numpy.ndarray, hppfcl.hppfcl.CollisionGeometry], Ellipsis] Returns a tuple of tuples: (placement_as_np, geometry) needed to perform collision checks with hppfcl .. py:property:: enclosing_volume :type: timor.Volume.Volume :abstractmethod: Obtain a spatial volume for the geometrical representation . The volume returned serves as a concrete and computationally tangible representation that can be used for various geometric operations, comparisons, or visualizations. .. py:method:: export_to_trimesh() :abstractmethod: Returns a trimesh representation of this geometry. .. py:method:: from_hppfcl(fcl) :classmethod: :abstractmethod: A helper function that transforms a generic hppfcl collision object to an according Geometry instance. :param fcl: The hppfcl collision object :return: An instance of the according Obstacle class, based on the kind of collision object handed over. .. py:method:: from_json_data(d, package_dir = None, *args, **kwargs) :classmethod: Takes a serialized geometry specification and returns the according Geometry instance. :param d: A serialized geometry :param package_dir: The top directory to which the mesh file paths are relative to. Necessary for meshes (only). .. py:method:: from_json_file(filepath, *args, **kwargs) :classmethod: Factory method to load a class instance from a json file. :param filepath: The path to the json file. :param args: Additional arguments to pass to the from_json_data factory method of the specific class. :param kwargs: Additional arguments to pass to the from_json_data factory method of the specific class. .. py:method:: from_json_string(description, package_dir = None) :classmethod: Takes a serialized geometry specification and returns the according Geometry instance. :param description: A serialized geometry :param package_dir: The top directory to which the mesh file paths are relative to. Necessary for meshes (only). .. py:method:: from_pin_geometry(geo) :classmethod: A helper function that transforms a generic pinocchio GeometryObject to an according Geometry instance. :param geo: The pinocchio GeometryObject :return: An instance of the according Obstacle class, based on the kind of collision object handed over. .. py:attribute:: hppfcl_representation :type: hppfcl.hppfcl.CollisionGeometry .. py:property:: measure_volume :type: float Returns the actual scalar volume. .. py:property:: parameters :type: Dict[str, Union[float, str]] :abstractmethod: Returns the class parameters in a json compliant format. .. py:attribute:: placement :type: timor.utilities.transformation.Transformation .. py:property:: serialized :type: List[Dict[str, any]] Creates a serialization of a Geometry that can be stored as json .. py:method:: to_json_data() The json-compatible serialization. .. py:method:: to_json_file(save_at, *args, **kwargs) Writes the instance to a json file. :param save_at: File location or folder to write the class to. .. py:method:: to_json_string() Returns a json string representation of this geometry. .. py:attribute:: type :type: GeometryType .. py:property:: urdf_properties :type: Tuple[str, Dict[str, Union[float, numpy.ndarray]]] :abstractmethod: Should return a tuple of (urdf_geometry_type, urdf_properties) .. py:property:: viz_object :type: Tuple[meshcat.geometry.Geometry, timor.utilities.transformation.Transformation] :abstractmethod: Returns a visual representation that can be used by meshcats 'set_object' and the according transform .. py:class:: GeometryType(*args, **kwds) .. autoapi-inheritance-diagram:: timor.Geometry.GeometryType :parts: 1 :private-bases: Wraps GeometryTypes in an Enum. Also contains the custom feature that it can be indexed by hppfcl Geometries due to inheriting from HppfclEnumMeta .. py:attribute:: BOX :value: 'box' .. py:attribute:: COMPOSED :value: 'composed' .. py:attribute:: CYLINDER :value: 'cylinder' .. py:attribute:: EMPTY :value: 'empty' .. py:attribute:: MESH :value: 'mesh' .. py:attribute:: SPHERE :value: 'sphere' .. py:attribute:: box :value: 'box' .. py:attribute:: composed :value: 'composed' .. py:attribute:: cylinder :value: 'cylinder' .. py:attribute:: empty :value: 'empty' .. py:attribute:: mesh :value: 'mesh' .. py:attribute:: sphere :value: 'sphere' .. py:class:: HppfclEnumMeta .. autoapi-inheritance-diagram:: timor.Geometry.HppfclEnumMeta :parts: 1 :private-bases: Custom Metaclass to alter Enum behavior Overriding __getitem__ here allows custom getitem use which makes it possible to map hppfcl geometries on enum values. .. py:method:: __getitem__(item) This getitem is commonly used for enums (when they are not instantiated before use) .. py:class:: Mesh(parameters, pose = Transformation.neutral(), hppfcl_representation = None) .. autoapi-inheritance-diagram:: timor.Geometry.Mesh :parts: 1 :private-bases: Meshes can be any geometry represented by a set of triangles The geometry class is the default way to describe a volume in space. :param parameters: Class-specific parameters defining the volume of the geometry. Will be unpacked in child classes :param pose: Transformation in world coordinates of this geometry :param hppfcl_representation: A hppfcl collision geometry representing this geometry in collision checks. If not provided, will be created. If provided, there will be no checks whether it fits the given parameters! .. py:method:: __deepcopy__(memodict={}) Must be implemented for Geometries, as hppfcl does not natively support it. .. py:method:: __eq__(other) We don't care about Mesh file paths, but equality of their collision geometries. Instead of using the undocumented equality operator of hppfcl, we compare the collision geometries directly. It should be valid to assume that two meshes with equal volume, radius, and center of their AABB are equal. .. py:method:: __getstate__() Return objects which will be pickled and saved. .. py:method:: __hash__() Scale can't always be hashed as it can be a numpy array .. py:method:: __setstate__(state) Take object from parameter and use it to retrieve class state. .. py:attribute:: __slots__ :value: () .. py:attribute:: _colors :type: Optional[numpy.ndarray] :value: None .. py:method:: _deduce_package_dir(filepath, content) :staticmethod: Logic for deducing the package directory if the JSONable object is loaded from a file. :param filepath: The path to the file. :param content: The content of the file parsed into a dictionary. :note: This method can be overridden by subclasses to provide custom package directory resolution; e.g. Task.py. .. py:attribute:: _filepath :type: pathlib.Path .. py:method:: _make_collision_geometry() This method generates the hppfcl-based collision geometry for this mesh used for collision detection. .. py:attribute:: _scale :type: Union[float, numpy.ndarray] .. py:property:: abs_filepath :type: pathlib.Path The absolute filepath of the mesh file. .. py:property:: as_hppfcl_collision_object :type: Tuple[hppfcl.hppfcl.CollisionObject, Ellipsis] Creates hppfcl CollisionObject(s) at the current pose of self. .. py:property:: collision_data :type: Tuple[Tuple[numpy.ndarray, hppfcl.hppfcl.CollisionGeometry], Ellipsis] Returns a tuple of tuples: (placement_as_np, geometry) needed to perform collision checks with hppfcl .. py:property:: enclosing_volume Direct volume extraction from a mesh is not supported here. Meshes represent geometries using a set of triangles, and while they provide a surface-level representation of a shape, they do not inherently describe its inner volume and often require the mesh to be closed and manifold. Moreover, certain ambiguities in mesh structures, like non-manifold edges and self-intersections, can complicate volume extraction. Given these complexities and inaccuracies, this property raises an exception to indicate that volume extraction from a mesh, in this context, is not supported. .. py:method:: export_to_trimesh() Return this mesh as a trimesh object. .. py:property:: filepath :type: pathlib.Path Keep access to these attributes private .. py:method:: from_hppfcl(fcl) :classmethod: Wraps a hppfcl Mesh in a Mesh instance. .. py:method:: from_json_data(d, package_dir = None, *args, **kwargs) :classmethod: Takes a serialized geometry specification and returns the according Geometry instance. :param d: A serialized geometry :param package_dir: The top directory to which the mesh file paths are relative to. Necessary for meshes (only). .. py:method:: from_json_file(filepath, *args, **kwargs) :classmethod: Factory method to load a class instance from a json file. :param filepath: The path to the json file. :param args: Additional arguments to pass to the from_json_data factory method of the specific class. :param kwargs: Additional arguments to pass to the from_json_data factory method of the specific class. .. py:method:: from_json_string(description, package_dir = None) :classmethod: Takes a serialized geometry specification and returns the according Geometry instance. :param description: A serialized geometry :param package_dir: The top directory to which the mesh file paths are relative to. Necessary for meshes (only). .. py:method:: from_pin_geometry(geo) :classmethod: A helper function that transforms a generic pinocchio GeometryObject to an according Geometry instance. :param geo: The pinocchio GeometryObject :return: An instance of the according Obstacle class, based on the kind of collision object handed over. .. py:attribute:: hppfcl_representation :type: hppfcl.hppfcl.CollisionGeometry .. py:property:: measure_volume :type: float Returns the volume of the mesh. Details can be found in "EFFICIENT FEATURE EXTRACTION FOR 2D/3D OBJECTS IN MESH REPRESENTATION" .. py:property:: parameters :type: Dict[str, Union[str, float]] The mesh geometry is the only one that does not return the full parameters: Package dir is not returned! The parameters are given as {'file': str, 'scale': [float, array]}, where scale is optional and can be boat, a single float or an array of (x, y, z)-scale. .. py:attribute:: placement :type: timor.utilities.transformation.Transformation .. py:method:: read_wrl(file) :staticmethod: Reads each sub-mesh from a wrl file into separate vertex and face arrays. The WRL format describes triangulated meshes and can contain multiple sub meshes that are parsed separately. We use these to store simplified convex decompositions of collision meshes. They are created with https://github.com/gaschler/bounding-mesh Based on example here: https://en.wikipedia.org/wiki/VRML .. py:property:: scale :type: numpy.ndarray Keep access to these attributes private and make sure scale is always a 3x1 vector (x, y, z) scale .. py:property:: serialized :type: List[Dict[str, any]] Creates a serialization of a Geometry that can be stored as json .. py:method:: to_json_data() The json-compatible serialization. .. py:method:: to_json_file(save_at, *args, **kwargs) Writes the instance to a json file. :param save_at: File location or folder to write the class to. .. py:method:: to_json_string() Returns a json string representation of this geometry. .. py:attribute:: type :type: GeometryType .. py:property:: urdf_properties :type: Tuple[str, Dict[str, Union[str, List[float]]]] Can only be saved as a dictionary if the mesh was loaded from a file and the file location is still known. .. py:property:: viz_object :type: Tuple[meshcat.geometry.Geometry, timor.utilities.transformation.Transformation] Returns a meshcat mesh .. py:class:: Sphere(parameters, pose = Transformation.neutral(), hppfcl_representation = None) .. autoapi-inheritance-diagram:: timor.Geometry.Sphere :parts: 1 :private-bases: A simple geometry with a full sphere. The geometry class is the default way to describe a volume in space. :param parameters: Class-specific parameters defining the volume of the geometry. Will be unpacked in child classes :param pose: Transformation in world coordinates of this geometry :param hppfcl_representation: A hppfcl collision geometry representing this geometry in collision checks. If not provided, will be created. If provided, there will be no checks whether it fits the given parameters! .. py:method:: __deepcopy__(memodict={}) Must be implemented for Geometries, as hppfcl does not natively support it. .. py:method:: __eq__(other) Compares two Geometry instances based on their type, parameters and placement. .. py:method:: __getstate__() Return objects which will be pickled and saved. .. py:method:: __hash__() Hashes the Geometry instance based on its type, parameters and placement. .. py:method:: __setstate__(state) Take object from parameter and use it to retrieve class state. .. py:attribute:: __slots__ :value: () .. py:method:: _deduce_package_dir(filepath, content) :staticmethod: Logic for deducing the package directory if the JSONable object is loaded from a file. :param filepath: The path to the file. :param content: The content of the file parsed into a dictionary. :note: This method can be overridden by subclasses to provide custom package directory resolution; e.g. Task.py. .. py:method:: _make_collision_geometry() A hppfcl sphere is centered in the symmetry axes of the sphere defined by radius .. py:property:: as_hppfcl_collision_object :type: Tuple[hppfcl.hppfcl.CollisionObject, Ellipsis] Creates hppfcl CollisionObject(s) at the current pose of self. .. py:property:: collision_data :type: Tuple[Tuple[numpy.ndarray, hppfcl.hppfcl.CollisionGeometry], Ellipsis] Returns a tuple of tuples: (placement_as_np, geometry) needed to perform collision checks with hppfcl .. py:property:: enclosing_volume :type: timor.Volume.SphereVolume Returns a sphere volume instance. .. py:method:: export_to_trimesh(subdivision = 5) Returns a trimesh sphere .. py:method:: from_hppfcl(fcl) :classmethod: Wraps a hppfcl Sphere in a Sphere instance. .. py:method:: from_json_data(d, package_dir = None, *args, **kwargs) :classmethod: Takes a serialized geometry specification and returns the according Geometry instance. :param d: A serialized geometry :param package_dir: The top directory to which the mesh file paths are relative to. Necessary for meshes (only). .. py:method:: from_json_file(filepath, *args, **kwargs) :classmethod: Factory method to load a class instance from a json file. :param filepath: The path to the json file. :param args: Additional arguments to pass to the from_json_data factory method of the specific class. :param kwargs: Additional arguments to pass to the from_json_data factory method of the specific class. .. py:method:: from_json_string(description, package_dir = None) :classmethod: Takes a serialized geometry specification and returns the according Geometry instance. :param description: A serialized geometry :param package_dir: The top directory to which the mesh file paths are relative to. Necessary for meshes (only). .. py:method:: from_pin_geometry(geo) :classmethod: A helper function that transforms a generic pinocchio GeometryObject to an according Geometry instance. :param geo: The pinocchio GeometryObject :return: An instance of the according Obstacle class, based on the kind of collision object handed over. .. py:attribute:: hppfcl_representation :type: hppfcl.hppfcl.CollisionGeometry .. py:property:: measure_volume :type: float Returns the actual scalar volume. .. py:attribute:: parameter_names :type: Tuple[str] :value: ('r',) .. py:property:: parameters :type: Dict[str, float] A sphere is defined by its radius only, given as {'r': float} .. py:attribute:: placement :type: timor.utilities.transformation.Transformation .. py:property:: r :type: float Keep access to these attributes private .. py:property:: serialized :type: List[Dict[str, any]] Creates a serialization of a Geometry that can be stored as json .. py:method:: to_json_data() The json-compatible serialization. .. py:method:: to_json_file(save_at, *args, **kwargs) Writes the instance to a json file. :param save_at: File location or folder to write the class to. .. py:method:: to_json_string() Returns a json string representation of this geometry. .. py:attribute:: type :type: GeometryType .. py:property:: urdf_properties :type: Tuple[str, Dict[str, float]] A sphere is completely described by its radius .. py:property:: viz_object :type: Tuple[meshcat.geometry.Geometry, timor.utilities.transformation.Transformation] Returns a meshcat sphere .. py:function:: _geometry_type2class(geometry_type) Returns the according Geometry class to represent a GeometryType. This needs to be wrapped as a function (cannot be class attribute or similar) because we need external access. :param geometry_type: Any of the GeometryType Enum types.