timor.Geometry

Classes

Box

A simple geometry with a box extending in x, y and z direction.

ComposedGeometry

A composed geometry is a collection of geometries that are combined in one instance.

Cylinder

A simple geometry with a cylinder extending in x-y plane (r) and z direction.

EmptyGeometry

This is a dummy geometry to being able to prevent setting a geometry to None.

Geometry

A class describing geometries.

GeometryType

Wraps GeometryTypes in an Enum.

HppfclEnumMeta

Custom Metaclass to alter Enum behavior

Mesh

Meshes can be any geometry represented by a set of triangles

Sphere

A simple geometry with a full sphere.

Functions

_geometry_type2class(geometry_type)

Returns the according Geometry class to represent a GeometryType.

Module Contents

class timor.Geometry.Box(parameters, pose=Transformation.neutral(), hppfcl_representation=None)
Inheritance diagram of timor.Geometry.Box

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.

Parameters:
  • parameters (Dict[str, Union[float, str]]) – Class-specific parameters defining the volume of the geometry. Will be unpacked in child classes

  • pose (timor.utilities.transformation.TransformationLike) – Transformation in world coordinates of this geometry

  • hppfcl_representation (Optional[hppfcl.hppfcl.CollisionGeometry]) – 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!

__deepcopy__(memodict={})

Must be implemented for Geometries, as hppfcl does not natively support it.

__eq__(other)

Compares two Geometry instances based on their type, parameters and placement.

Parameters:

other (Geometry)

__getstate__()

Return objects which will be pickled and saved.

__hash__()

Hashes the Geometry instance based on its type, parameters and placement.

__setstate__(state)

Take object from parameter and use it to retrieve class state.

__slots__ = ()
static _deduce_package_dir(filepath, content)

Logic for deducing the package directory if the JSONable object is loaded from a file.

Parameters:
  • filepath (pathlib.Path) – The path to the file.

  • content (Union[Dict, List]) – 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.

Return type:

pathlib.Path

_make_collision_geometry()

A hppfcl box is centered in the symmetry axes of the box defined by width, height, depth

Return type:

hppfcl.hppfcl.CollisionGeometry

property as_hppfcl_collision_object: Tuple[hppfcl.hppfcl.CollisionObject, Ellipsis]

Creates hppfcl CollisionObject(s) at the current pose of self.

Return type:

Tuple[hppfcl.hppfcl.CollisionObject, Ellipsis]

property collision_data: Tuple[Tuple[numpy.ndarray, hppfcl.hppfcl.CollisionGeometry], Ellipsis]

Returns a tuple of tuples: (placement_as_np, geometry) needed to perform collision checks with hppfcl

Return type:

Tuple[Tuple[numpy.ndarray, hppfcl.hppfcl.CollisionGeometry], Ellipsis]

property enclosing_volume: timor.Volume.BoxVolume

Returns a box volume instance.

Return type:

timor.Volume.BoxVolume

export_to_trimesh()

Returns a trimesh box

Return type:

trimesh.base.Trimesh

classmethod from_hppfcl(fcl)

Wraps a hppfcl Box in a Box instance.

Parameters:

fcl (hppfcl.hppfcl.CollisionObject)

Return type:

Geometry

classmethod from_json_data(d, package_dir=None, *args, **kwargs)

Takes a serialized geometry specification and returns the according Geometry instance.

Parameters:
  • d (Union[List, Dict[str, any]]) – A serialized geometry

  • package_dir (Optional[pathlib.Path]) – The top directory to which the mesh file paths are relative to. Necessary for meshes (only).

Return type:

Geometry

classmethod from_json_file(filepath, *args, **kwargs)

Factory method to load a class instance from a json file.

Parameters:
  • filepath (Union[pathlib.Path, str]) – The path to the json file.

  • args – Additional arguments to pass to the from_json_data factory method of the specific class.

  • kwargs – Additional arguments to pass to the from_json_data factory method of the specific class.

classmethod from_json_string(description, package_dir=None)

Takes a serialized geometry specification and returns the according Geometry instance.

Parameters:
  • description (str) – A serialized geometry

  • package_dir (Optional[pathlib.Path]) – The top directory to which the mesh file paths are relative to. Necessary for meshes (only).

Return type:

Geometry

classmethod from_pin_geometry(geo)

A helper function that transforms a generic pinocchio GeometryObject to an according Geometry instance.

Parameters:

geo (pinocchio.GeometryObject) – The pinocchio GeometryObject

Returns:

An instance of the according Obstacle class, based on the kind of collision object handed over.

Return type:

Geometry

hppfcl_representation: hppfcl.hppfcl.CollisionGeometry
property measure_volume: float

Returns the actual scalar volume.

Return type:

float

parameter_names: Tuple[str, str, str] = ('x', 'y', 'z')
property parameters: Dict[str, float]

Box parameters are fully described by x, y and z, each one being a float: {‘x’: f, ‘y’: f, ‘z’: f}

Return type:

Dict[str, float]

placement: timor.utilities.transformation.Transformation
property serialized: List[Dict[str, any]]

Creates a serialization of a Geometry that can be stored as json

Return type:

List[Dict[str, any]]

to_json_data()

The json-compatible serialization.

to_json_file(save_at, *args, **kwargs)

Writes the instance to a json file.

Parameters:

save_at (Union[pathlib.Path, str]) – File location or folder to write the class to.

to_json_string()

Returns a json string representation of this geometry.

Return type:

str

type: GeometryType
property urdf_properties: Tuple[str, Dict[str, List[float]]]

A box in URDF is described by [x, y, z]

Return type:

Tuple[str, Dict[str, List[float]]]

property viz_object: Tuple[meshcat.geometry.Geometry, timor.utilities.transformation.Transformation]

Returns a meshcat box

Return type:

Tuple[meshcat.geometry.Geometry, timor.utilities.transformation.Transformation]

property x: float

Keep access to these attributes private

Return type:

float

property y: float

Keep access to these attributes private

Return type:

float

property z: float

Keep access to these attributes private

Return type:

float

class timor.Geometry.ComposedGeometry(geometries)
Inheritance diagram of timor.Geometry.ComposedGeometry

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.

Parameters:

geometries (Iterable[Geometry]) – An iterable of geometries that are combined in this composed geometry.

__deepcopy__(memodict={})

Must be implemented for Geometries, as hppfcl does not natively support it.

__eq__(other)

Equality is defined as having the same composing geometries.

__getstate__()

Return objects which will be pickled and saved.

__hash__()

Hash is defined as the hash of the composing geometries.

__setstate__(state)

Take object from parameter and use it to retrieve class state.

__slots__ = ()
_composing_geometries: List[Geometry]
static _deduce_package_dir(filepath, content)

Logic for deducing the package directory if the JSONable object is loaded from a file.

Parameters:
  • filepath (pathlib.Path) – The path to the file.

  • content (Union[Dict, List]) – 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.

Return type:

pathlib.Path

abstractmethod _make_collision_geometry()

This method is usually only called in the init, which is overwritten for this class.

property as_hppfcl_collision_object: Tuple[hppfcl.hppfcl.CollisionObject, Ellipsis]

Creates hppfcl CollisionObjects at the current placement of self.

Return type:

Tuple[hppfcl.hppfcl.CollisionObject, Ellipsis]

property collision_data: Tuple[Tuple[numpy.ndarray, hppfcl.hppfcl.CollisionGeometry], Ellipsis]

Composed Geometries are the only ones with more than one element in the collision data

Return type:

Tuple[Tuple[numpy.ndarray, hppfcl.hppfcl.CollisionGeometry], Ellipsis]

collision_geometry = None
property composing_geometries: Tuple[Geometry]

This attribute should be read-only, therefore the leading underscore and the return as tuple.

Return type:

Tuple[Geometry]

property enclosing_volume

For now, composed geometries do not have a volume.

export_to_trimesh()

Returns a trimesh representation of this geometry.

Return type:

trimesh.base.Trimesh

classmethod from_hppfcl(fcl)
Abstractmethod:

Parameters:

fcl (hppfcl.hppfcl.CollisionObject)

Return type:

Geometry

hppfcl does not know the concept of composed geometries.

classmethod from_json_data(d, package_dir=None, *args, **kwargs)

Takes a serialized geometry specification and returns the according Geometry instance.

Parameters:
  • d (Union[List, Dict[str, any]]) – A serialized geometry

  • package_dir (Optional[pathlib.Path]) – The top directory to which the mesh file paths are relative to. Necessary for meshes (only).

Return type:

Geometry

classmethod from_json_file(filepath, *args, **kwargs)

Factory method to load a class instance from a json file.

Parameters:
  • filepath (Union[pathlib.Path, str]) – The path to the json file.

  • args – Additional arguments to pass to the from_json_data factory method of the specific class.

  • kwargs – Additional arguments to pass to the from_json_data factory method of the specific class.

classmethod from_json_string(description, package_dir=None)

Takes a serialized geometry specification and returns the according Geometry instance.

Parameters:
  • description (str) – A serialized geometry

  • package_dir (Optional[pathlib.Path]) – The top directory to which the mesh file paths are relative to. Necessary for meshes (only).

Return type:

Geometry

classmethod from_pin_geometry(geo)

A helper function that transforms a generic pinocchio GeometryObject to an according Geometry instance.

Parameters:

geo (pinocchio.GeometryObject) – The pinocchio GeometryObject

Returns:

An instance of the according Obstacle class, based on the kind of collision object handed over.

Return type:

Geometry

hppfcl_representation: hppfcl.hppfcl.CollisionGeometry
property measure_volume: float

The scalar volume of a composed geometry is the sum of the volumes of the composing geometries.

Return type:

float

property parameters: Dict[str, float | str]
Abstractmethod:

Return type:

Dict[str, Union[float, str]]

This class cannot be instantiated from parameters, so this attribute is also not necessary.

placement: timor.utilities.transformation.Transformation
property serialized: List[Dict[str, any]]

Creates a json-compliant dictionary of a Geometry

Return type:

List[Dict[str, any]]

to_json_data()

The json-compatible serialization.

to_json_file(save_at, *args, **kwargs)

Writes the instance to a json file.

Parameters:

save_at (Union[pathlib.Path, str]) – File location or folder to write the class to.

to_json_string()

Returns a json string representation of this geometry.

Return type:

str

type: GeometryType
property urdf_properties: Tuple[str, Dict[str, float | numpy.ndarray]]
Abstractmethod:

Return type:

Tuple[str, Dict[str, Union[float, numpy.ndarray]]]

urdf does not know the concept of composed geometries for collisions.

property viz_object: Tuple[meshcat.geometry.Geometry, timor.utilities.transformation.Transformation]
Abstractmethod:

Return type:

Tuple[meshcat.geometry.Geometry, timor.utilities.transformation.Transformation]

meshcat geometries can only represent a single geometry, so this method is not implemented.

class timor.Geometry.Cylinder(parameters, pose=Transformation.neutral(), hppfcl_representation=None)
Inheritance diagram of timor.Geometry.Cylinder

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.

Parameters:
  • parameters (Dict[str, Union[float, str]]) – Class-specific parameters defining the volume of the geometry. Will be unpacked in child classes

  • pose (timor.utilities.transformation.TransformationLike) – Transformation in world coordinates of this geometry

  • hppfcl_representation (Optional[hppfcl.hppfcl.CollisionGeometry]) – 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!

__deepcopy__(memodict={})

Must be implemented for Geometries, as hppfcl does not natively support it.

__eq__(other)

Compares two Geometry instances based on their type, parameters and placement.

Parameters:

other (Geometry)

__getstate__()

Return objects which will be pickled and saved.

__hash__()

Hashes the Geometry instance based on its type, parameters and placement.

__setstate__(state)

Take object from parameter and use it to retrieve class state.

__slots__ = ()
static _deduce_package_dir(filepath, content)

Logic for deducing the package directory if the JSONable object is loaded from a file.

Parameters:
  • filepath (pathlib.Path) – The path to the file.

  • content (Union[Dict, List]) – 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.

Return type:

pathlib.Path

_make_collision_geometry()

A hppfcl cylinder is centered in the symmetry axes of the cylinder defined by radius and height.

Return type:

hppfcl.hppfcl.CollisionGeometry

property as_hppfcl_collision_object: Tuple[hppfcl.hppfcl.CollisionObject, Ellipsis]

Creates hppfcl CollisionObject(s) at the current pose of self.

Return type:

Tuple[hppfcl.hppfcl.CollisionObject, Ellipsis]

property collision_data: Tuple[Tuple[numpy.ndarray, hppfcl.hppfcl.CollisionGeometry], Ellipsis]

Returns a tuple of tuples: (placement_as_np, geometry) needed to perform collision checks with hppfcl

Return type:

Tuple[Tuple[numpy.ndarray, hppfcl.hppfcl.CollisionGeometry], Ellipsis]

property enclosing_volume: timor.Volume.CylinderVolume

Returns a cylinder volume instance.

Return type:

timor.Volume.CylinderVolume

export_to_trimesh()

Returns a trimesh cylinder

Return type:

trimesh.base.Trimesh

classmethod from_hppfcl(fcl)

Wraps a hppfcl Cylinder in a Cylinder instance.

Parameters:

fcl (hppfcl.hppfcl.CollisionObject)

Return type:

Geometry

classmethod from_json_data(d, package_dir=None, *args, **kwargs)

Takes a serialized geometry specification and returns the according Geometry instance.

Parameters:
  • d (Union[List, Dict[str, any]]) – A serialized geometry

  • package_dir (Optional[pathlib.Path]) – The top directory to which the mesh file paths are relative to. Necessary for meshes (only).

Return type:

Geometry

classmethod from_json_file(filepath, *args, **kwargs)

Factory method to load a class instance from a json file.

Parameters:
  • filepath (Union[pathlib.Path, str]) – The path to the json file.

  • args – Additional arguments to pass to the from_json_data factory method of the specific class.

  • kwargs – Additional arguments to pass to the from_json_data factory method of the specific class.

classmethod from_json_string(description, package_dir=None)

Takes a serialized geometry specification and returns the according Geometry instance.

Parameters:
  • description (str) – A serialized geometry

  • package_dir (Optional[pathlib.Path]) – The top directory to which the mesh file paths are relative to. Necessary for meshes (only).

Return type:

Geometry

classmethod from_pin_geometry(geo)

A helper function that transforms a generic pinocchio GeometryObject to an according Geometry instance.

Parameters:

geo (pinocchio.GeometryObject) – The pinocchio GeometryObject

Returns:

An instance of the according Obstacle class, based on the kind of collision object handed over.

Return type:

Geometry

hppfcl_representation: hppfcl.hppfcl.CollisionGeometry
property measure_volume: float

Returns the actual scalar volume.

Return type:

float

parameter_names: Tuple[str, str] = ('r', 'z')
property parameters: Dict[str, float]

Cylinder parameters are fully described by r and z: {‘r’: float, ‘z’: float}

Return type:

Dict[str, float]

placement: timor.utilities.transformation.Transformation
property r: float

Keep access to these attributes private

Return type:

float

property serialized: List[Dict[str, any]]

Creates a serialization of a Geometry that can be stored as json

Return type:

List[Dict[str, any]]

to_json_data()

The json-compatible serialization.

to_json_file(save_at, *args, **kwargs)

Writes the instance to a json file.

Parameters:

save_at (Union[pathlib.Path, str]) – File location or folder to write the class to.

to_json_string()

Returns a json string representation of this geometry.

Return type:

str

type: GeometryType
property urdf_properties: Tuple[str, Dict[str, float]]

A cylinder is specified with a radius and an extension in z-direction with origin in the symmetry axes

Return type:

Tuple[str, Dict[str, float]]

property viz_object: Tuple[meshcat.geometry.Geometry, timor.utilities.transformation.Transformation]

The meshcat cylinder is y-aligned while we expect it to be z-aligned

Return type:

Tuple[meshcat.geometry.Geometry, timor.utilities.transformation.Transformation]

property z: float

Keep access to these attributes private

Return type:

float

class timor.Geometry.EmptyGeometry(parameters=None, pose=Transformation.neutral(), hppfcl_representation=None)
Inheritance diagram of timor.Geometry.EmptyGeometry

This is a dummy geometry to being able to prevent setting a geometry to None.

For an empty geometry, the parameters are not used.

Parameters:
  • parameters (Dict[str, Union[float, str]])

  • pose (timor.utilities.transformation.TransformationLike)

  • hppfcl_representation (Optional[hppfcl.hppfcl.CollisionGeometry])

__deepcopy__(memodict={})

Must be implemented for Geometries, as hppfcl does not natively support it.

__eq__(other)

Empty geometries are equal to other empty geometries.

__getstate__()

Return objects which will be pickled and saved.

__hash__()

Empty geometries are equal to other empty geometries.

__setstate__(state)

Take object from parameter and use it to retrieve class state.

__slots__ = ()
static _deduce_package_dir(filepath, content)

Logic for deducing the package directory if the JSONable object is loaded from a file.

Parameters:
  • filepath (pathlib.Path) – The path to the file.

  • content (Union[Dict, List]) – 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.

Return type:

pathlib.Path

_make_collision_geometry()

No Geometry, no collision object.

Return type:

hppfcl.hppfcl.CollisionGeometry

property as_hppfcl_collision_object: Tuple[hppfcl.hppfcl.CollisionObject, Ellipsis]

An empty geometry does not have a collision object.

Return type:

Tuple[hppfcl.hppfcl.CollisionObject, Ellipsis]

property collision_data: Tuple[Tuple[numpy.ndarray, hppfcl.hppfcl.CollisionGeometry], Ellipsis]

No Geometry, no collision object.

Return type:

Tuple[Tuple[numpy.ndarray, hppfcl.hppfcl.CollisionGeometry], Ellipsis]

property enclosing_volume

No need to calculate volume for empty geometry.

export_to_trimesh()

Returns an empty trimesh as the representation of this geometry.

Return type:

trimesh.base.Trimesh

classmethod from_hppfcl(fcl)
Abstractmethod:

Parameters:

fcl (hppfcl.hppfcl.CollisionObject)

Return type:

Geometry

This method is not implemented as it is not necessary.

classmethod from_json_data(d, package_dir=None, *args, **kwargs)

Takes a serialized geometry specification and returns the according Geometry instance.

Parameters:
  • d (Union[List, Dict[str, any]]) – A serialized geometry

  • package_dir (Optional[pathlib.Path]) – The top directory to which the mesh file paths are relative to. Necessary for meshes (only).

Return type:

Geometry

classmethod from_json_file(filepath, *args, **kwargs)

Factory method to load a class instance from a json file.

Parameters:
  • filepath (Union[pathlib.Path, str]) – The path to the json file.

  • args – Additional arguments to pass to the from_json_data factory method of the specific class.

  • kwargs – Additional arguments to pass to the from_json_data factory method of the specific class.

classmethod from_json_string(description, package_dir=None)

Takes a serialized geometry specification and returns the according Geometry instance.

Parameters:
  • description (str) – A serialized geometry

  • package_dir (Optional[pathlib.Path]) – The top directory to which the mesh file paths are relative to. Necessary for meshes (only).

Return type:

Geometry

classmethod from_pin_geometry(geo)

A helper function that transforms a generic pinocchio GeometryObject to an according Geometry instance.

Parameters:

geo (pinocchio.GeometryObject) – The pinocchio GeometryObject

Returns:

An instance of the according Obstacle class, based on the kind of collision object handed over.

Return type:

Geometry

hppfcl_representation: hppfcl.hppfcl.CollisionGeometry
property measure_volume: float

No Geometry, no volume.

Return type:

float

property parameters: Dict[str, float | str]

No Geometry, no parameters.

Return type:

Dict[str, Union[float, str]]

placement: timor.utilities.transformation.Transformation
property serialized: List[Dict[str, any]]

Creates a serialization of a Geometry that can be stored as json

Return type:

List[Dict[str, any]]

to_json_data()

The json-compatible serialization.

to_json_file(save_at, *args, **kwargs)

Writes the instance to a json file.

Parameters:

save_at (Union[pathlib.Path, str]) – File location or folder to write the class to.

to_json_string()

Returns a json string representation of this geometry.

Return type:

str

type: GeometryType
property urdf_properties: Tuple[str, Dict[str, float | numpy.ndarray]]
Abstractmethod:

Return type:

Tuple[str, Dict[str, Union[float, numpy.ndarray]]]

Omit this object when serializing.

property viz_object: Tuple[meshcat.geometry.Geometry, timor.utilities.transformation.Transformation]
Abstractmethod:

Return type:

Tuple[meshcat.geometry.Geometry, timor.utilities.transformation.Transformation]

Omit this object when serializing.

class timor.Geometry.Geometry(parameters, pose=Transformation.neutral(), hppfcl_representation=None)
Inheritance diagram of timor.Geometry.Geometry

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.

Parameters:
  • parameters (Dict[str, Union[float, str]]) – Class-specific parameters defining the volume of the geometry. Will be unpacked in child classes

  • pose (timor.utilities.transformation.TransformationLike) – Transformation in world coordinates of this geometry

  • hppfcl_representation (Optional[hppfcl.hppfcl.CollisionGeometry]) – 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!

__deepcopy__(memodict={})

Must be implemented for Geometries, as hppfcl does not natively support it.

__eq__(other)

Compares two Geometry instances based on their type, parameters and placement.

Parameters:

other (Geometry)

__getstate__()

Return objects which will be pickled and saved.

__hash__()

Hashes the Geometry instance based on its type, parameters and placement.

__setstate__(state)

Take object from parameter and use it to retrieve class state.

__slots__ = ()
static _deduce_package_dir(filepath, content)

Logic for deducing the package directory if the JSONable object is loaded from a file.

Parameters:
  • filepath (pathlib.Path) – The path to the file.

  • content (Union[Dict, List]) – 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.

Return type:

pathlib.Path

abstractmethod _make_collision_geometry()

Creates a hppfcl collision object aligned with the parameters of the Geometry

Return type:

hppfcl.hppfcl.CollisionGeometry

property as_hppfcl_collision_object: Tuple[hppfcl.hppfcl.CollisionObject, Ellipsis]

Creates hppfcl CollisionObject(s) at the current pose of self.

Return type:

Tuple[hppfcl.hppfcl.CollisionObject, Ellipsis]

property collision_data: Tuple[Tuple[numpy.ndarray, hppfcl.hppfcl.CollisionGeometry], Ellipsis]

Returns a tuple of tuples: (placement_as_np, geometry) needed to perform collision checks with hppfcl

Return type:

Tuple[Tuple[numpy.ndarray, hppfcl.hppfcl.CollisionGeometry], Ellipsis]

property enclosing_volume: timor.Volume.Volume
Abstractmethod:

Return type:

timor.Volume.Volume

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.

abstractmethod export_to_trimesh()

Returns a trimesh representation of this geometry.

Return type:

trimesh.base.Trimesh

classmethod from_hppfcl(fcl)
Abstractmethod:

Parameters:

fcl (hppfcl.hppfcl.CollisionObject)

Return type:

Geometry

A helper function that transforms a generic hppfcl collision object to an according Geometry instance.

Parameters:

fcl (hppfcl.hppfcl.CollisionObject) – The hppfcl collision object

Returns:

An instance of the according Obstacle class, based on the kind of collision object handed over.

Return type:

Geometry

classmethod from_json_data(d, package_dir=None, *args, **kwargs)

Takes a serialized geometry specification and returns the according Geometry instance.

Parameters:
  • d (Union[List, Dict[str, any]]) – A serialized geometry

  • package_dir (Optional[pathlib.Path]) – The top directory to which the mesh file paths are relative to. Necessary for meshes (only).

Return type:

Geometry

classmethod from_json_file(filepath, *args, **kwargs)

Factory method to load a class instance from a json file.

Parameters:
  • filepath (Union[pathlib.Path, str]) – The path to the json file.

  • args – Additional arguments to pass to the from_json_data factory method of the specific class.

  • kwargs – Additional arguments to pass to the from_json_data factory method of the specific class.

classmethod from_json_string(description, package_dir=None)

Takes a serialized geometry specification and returns the according Geometry instance.

Parameters:
  • description (str) – A serialized geometry

  • package_dir (Optional[pathlib.Path]) – The top directory to which the mesh file paths are relative to. Necessary for meshes (only).

Return type:

Geometry

classmethod from_pin_geometry(geo)

A helper function that transforms a generic pinocchio GeometryObject to an according Geometry instance.

Parameters:

geo (pinocchio.GeometryObject) – The pinocchio GeometryObject

Returns:

An instance of the according Obstacle class, based on the kind of collision object handed over.

Return type:

Geometry

hppfcl_representation: hppfcl.hppfcl.CollisionGeometry
property measure_volume: float

Returns the actual scalar volume.

Return type:

float

property parameters: Dict[str, float | str]
Abstractmethod:

Return type:

Dict[str, Union[float, str]]

Returns the class parameters in a json compliant format.

placement: timor.utilities.transformation.Transformation
property serialized: List[Dict[str, any]]

Creates a serialization of a Geometry that can be stored as json

Return type:

List[Dict[str, any]]

to_json_data()

The json-compatible serialization.

to_json_file(save_at, *args, **kwargs)

Writes the instance to a json file.

Parameters:

save_at (Union[pathlib.Path, str]) – File location or folder to write the class to.

to_json_string()

Returns a json string representation of this geometry.

Return type:

str

type: GeometryType
property urdf_properties: Tuple[str, Dict[str, float | numpy.ndarray]]
Abstractmethod:

Return type:

Tuple[str, Dict[str, Union[float, numpy.ndarray]]]

Should return a tuple of (urdf_geometry_type, urdf_properties)

property viz_object: Tuple[meshcat.geometry.Geometry, timor.utilities.transformation.Transformation]
Abstractmethod:

Return type:

Tuple[meshcat.geometry.Geometry, timor.utilities.transformation.Transformation]

Returns a visual representation that can be used by meshcats ‘set_object’ and the according transform

class timor.Geometry.GeometryType(*args, **kwds)
Inheritance diagram of timor.Geometry.GeometryType

Wraps GeometryTypes in an Enum.

Also contains the custom feature that it can be indexed by hppfcl Geometries due to inheriting from HppfclEnumMeta

BOX = 'box'
COMPOSED = 'composed'
CYLINDER = 'cylinder'
EMPTY = 'empty'
MESH = 'mesh'
SPHERE = 'sphere'
box = 'box'
composed = 'composed'
cylinder = 'cylinder'
empty = 'empty'
mesh = 'mesh'
sphere = 'sphere'
class timor.Geometry.HppfclEnumMeta
Inheritance diagram of timor.Geometry.HppfclEnumMeta

Custom Metaclass to alter Enum behavior

Overriding __getitem__ here allows custom getitem use which makes it possible to map hppfcl geometries on enum values.

__getitem__(item)

This getitem is commonly used for enums (when they are not instantiated before use)

class timor.Geometry.Mesh(parameters, pose=Transformation.neutral(), hppfcl_representation=None)
Inheritance diagram of timor.Geometry.Mesh

Meshes can be any geometry represented by a set of triangles

The geometry class is the default way to describe a volume in space.

Parameters:
  • parameters (Dict[str, Union[float, str]]) – Class-specific parameters defining the volume of the geometry. Will be unpacked in child classes

  • pose (timor.utilities.transformation.TransformationLike) – Transformation in world coordinates of this geometry

  • hppfcl_representation (Optional[hppfcl.hppfcl.CollisionGeometry]) – 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!

__deepcopy__(memodict={})

Must be implemented for Geometries, as hppfcl does not natively support it.

__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.

Parameters:

other (Geometry)

__getstate__()

Return objects which will be pickled and saved.

__hash__()

Scale can’t always be hashed as it can be a numpy array

__setstate__(state)

Take object from parameter and use it to retrieve class state.

__slots__ = ()
_colors: numpy.ndarray | None = None
static _deduce_package_dir(filepath, content)

Logic for deducing the package directory if the JSONable object is loaded from a file.

Parameters:
  • filepath (pathlib.Path) – The path to the file.

  • content (Union[Dict, List]) – 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.

Return type:

pathlib.Path

_filepath: pathlib.Path
_make_collision_geometry()

This method generates the hppfcl-based collision geometry for this mesh used for collision detection.

Return type:

hppfcl.hppfcl.CollisionGeometry

_scale: float | numpy.ndarray
property abs_filepath: pathlib.Path

The absolute filepath of the mesh file.

Return type:

pathlib.Path

property as_hppfcl_collision_object: Tuple[hppfcl.hppfcl.CollisionObject, Ellipsis]

Creates hppfcl CollisionObject(s) at the current pose of self.

Return type:

Tuple[hppfcl.hppfcl.CollisionObject, Ellipsis]

property collision_data: Tuple[Tuple[numpy.ndarray, hppfcl.hppfcl.CollisionGeometry], Ellipsis]

Returns a tuple of tuples: (placement_as_np, geometry) needed to perform collision checks with hppfcl

Return type:

Tuple[Tuple[numpy.ndarray, hppfcl.hppfcl.CollisionGeometry], Ellipsis]

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.

export_to_trimesh()

Return this mesh as a trimesh object.

Return type:

trimesh.base.Trimesh

property filepath: pathlib.Path

Keep access to these attributes private

Return type:

pathlib.Path

classmethod from_hppfcl(fcl)

Wraps a hppfcl Mesh in a Mesh instance.

Parameters:

fcl (hppfcl.hppfcl.CollisionObject)

Return type:

Geometry

classmethod from_json_data(d, package_dir=None, *args, **kwargs)

Takes a serialized geometry specification and returns the according Geometry instance.

Parameters:
  • d (Union[List, Dict[str, any]]) – A serialized geometry

  • package_dir (Optional[pathlib.Path]) – The top directory to which the mesh file paths are relative to. Necessary for meshes (only).

Return type:

Geometry

classmethod from_json_file(filepath, *args, **kwargs)

Factory method to load a class instance from a json file.

Parameters:
  • filepath (Union[pathlib.Path, str]) – The path to the json file.

  • args – Additional arguments to pass to the from_json_data factory method of the specific class.

  • kwargs – Additional arguments to pass to the from_json_data factory method of the specific class.

classmethod from_json_string(description, package_dir=None)

Takes a serialized geometry specification and returns the according Geometry instance.

Parameters:
  • description (str) – A serialized geometry

  • package_dir (Optional[pathlib.Path]) – The top directory to which the mesh file paths are relative to. Necessary for meshes (only).

Return type:

Geometry

classmethod from_pin_geometry(geo)

A helper function that transforms a generic pinocchio GeometryObject to an according Geometry instance.

Parameters:

geo (pinocchio.GeometryObject) – The pinocchio GeometryObject

Returns:

An instance of the according Obstacle class, based on the kind of collision object handed over.

Return type:

Geometry

hppfcl_representation: hppfcl.hppfcl.CollisionGeometry
property measure_volume: float

Returns the volume of the mesh.

Details can be found in “EFFICIENT FEATURE EXTRACTION FOR 2D/3D OBJECTS IN MESH REPRESENTATION”

Return type:

float

property parameters: Dict[str, 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.

Return type:

Dict[str, Union[str, float]]

placement: timor.utilities.transformation.Transformation
static read_wrl(file)

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

Parameters:

file (pathlib.Path)

Return type:

Tuple[Tuple[numpy.ndarray, Ellipsis], Tuple[numpy.ndarray, Ellipsis]]

property scale: numpy.ndarray

Keep access to these attributes private and make sure scale is always a 3x1 vector (x, y, z) scale

Return type:

numpy.ndarray

property serialized: List[Dict[str, any]]

Creates a serialization of a Geometry that can be stored as json

Return type:

List[Dict[str, any]]

to_json_data()

The json-compatible serialization.

to_json_file(save_at, *args, **kwargs)

Writes the instance to a json file.

Parameters:

save_at (Union[pathlib.Path, str]) – File location or folder to write the class to.

to_json_string()

Returns a json string representation of this geometry.

Return type:

str

type: GeometryType
property urdf_properties: Tuple[str, Dict[str, 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.

Return type:

Tuple[str, Dict[str, Union[str, List[float]]]]

property viz_object: Tuple[meshcat.geometry.Geometry, timor.utilities.transformation.Transformation]

Returns a meshcat mesh

Return type:

Tuple[meshcat.geometry.Geometry, timor.utilities.transformation.Transformation]

class timor.Geometry.Sphere(parameters, pose=Transformation.neutral(), hppfcl_representation=None)
Inheritance diagram of timor.Geometry.Sphere

A simple geometry with a full sphere.

The geometry class is the default way to describe a volume in space.

Parameters:
  • parameters (Dict[str, Union[float, str]]) – Class-specific parameters defining the volume of the geometry. Will be unpacked in child classes

  • pose (timor.utilities.transformation.TransformationLike) – Transformation in world coordinates of this geometry

  • hppfcl_representation (Optional[hppfcl.hppfcl.CollisionGeometry]) – 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!

__deepcopy__(memodict={})

Must be implemented for Geometries, as hppfcl does not natively support it.

__eq__(other)

Compares two Geometry instances based on their type, parameters and placement.

Parameters:

other (Geometry)

__getstate__()

Return objects which will be pickled and saved.

__hash__()

Hashes the Geometry instance based on its type, parameters and placement.

__setstate__(state)

Take object from parameter and use it to retrieve class state.

__slots__ = ()
static _deduce_package_dir(filepath, content)

Logic for deducing the package directory if the JSONable object is loaded from a file.

Parameters:
  • filepath (pathlib.Path) – The path to the file.

  • content (Union[Dict, List]) – 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.

Return type:

pathlib.Path

_make_collision_geometry()

A hppfcl sphere is centered in the symmetry axes of the sphere defined by radius

Return type:

hppfcl.hppfcl.CollisionGeometry

property as_hppfcl_collision_object: Tuple[hppfcl.hppfcl.CollisionObject, Ellipsis]

Creates hppfcl CollisionObject(s) at the current pose of self.

Return type:

Tuple[hppfcl.hppfcl.CollisionObject, Ellipsis]

property collision_data: Tuple[Tuple[numpy.ndarray, hppfcl.hppfcl.CollisionGeometry], Ellipsis]

Returns a tuple of tuples: (placement_as_np, geometry) needed to perform collision checks with hppfcl

Return type:

Tuple[Tuple[numpy.ndarray, hppfcl.hppfcl.CollisionGeometry], Ellipsis]

property enclosing_volume: timor.Volume.SphereVolume

Returns a sphere volume instance.

Return type:

timor.Volume.SphereVolume

export_to_trimesh(subdivision=5)

Returns a trimesh sphere

Parameters:

subdivision (int)

Return type:

trimesh.base.Trimesh

classmethod from_hppfcl(fcl)

Wraps a hppfcl Sphere in a Sphere instance.

Parameters:

fcl (hppfcl.hppfcl.CollisionObject)

Return type:

Geometry

classmethod from_json_data(d, package_dir=None, *args, **kwargs)

Takes a serialized geometry specification and returns the according Geometry instance.

Parameters:
  • d (Union[List, Dict[str, any]]) – A serialized geometry

  • package_dir (Optional[pathlib.Path]) – The top directory to which the mesh file paths are relative to. Necessary for meshes (only).

Return type:

Geometry

classmethod from_json_file(filepath, *args, **kwargs)

Factory method to load a class instance from a json file.

Parameters:
  • filepath (Union[pathlib.Path, str]) – The path to the json file.

  • args – Additional arguments to pass to the from_json_data factory method of the specific class.

  • kwargs – Additional arguments to pass to the from_json_data factory method of the specific class.

classmethod from_json_string(description, package_dir=None)

Takes a serialized geometry specification and returns the according Geometry instance.

Parameters:
  • description (str) – A serialized geometry

  • package_dir (Optional[pathlib.Path]) – The top directory to which the mesh file paths are relative to. Necessary for meshes (only).

Return type:

Geometry

classmethod from_pin_geometry(geo)

A helper function that transforms a generic pinocchio GeometryObject to an according Geometry instance.

Parameters:

geo (pinocchio.GeometryObject) – The pinocchio GeometryObject

Returns:

An instance of the according Obstacle class, based on the kind of collision object handed over.

Return type:

Geometry

hppfcl_representation: hppfcl.hppfcl.CollisionGeometry
property measure_volume: float

Returns the actual scalar volume.

Return type:

float

parameter_names: Tuple[str] = ('r',)
property parameters: Dict[str, float]

A sphere is defined by its radius only, given as {‘r’: float}

Return type:

Dict[str, float]

placement: timor.utilities.transformation.Transformation
property r: float

Keep access to these attributes private

Return type:

float

property serialized: List[Dict[str, any]]

Creates a serialization of a Geometry that can be stored as json

Return type:

List[Dict[str, any]]

to_json_data()

The json-compatible serialization.

to_json_file(save_at, *args, **kwargs)

Writes the instance to a json file.

Parameters:

save_at (Union[pathlib.Path, str]) – File location or folder to write the class to.

to_json_string()

Returns a json string representation of this geometry.

Return type:

str

type: GeometryType
property urdf_properties: Tuple[str, Dict[str, float]]

A sphere is completely described by its radius

Return type:

Tuple[str, Dict[str, float]]

property viz_object: Tuple[meshcat.geometry.Geometry, timor.utilities.transformation.Transformation]

Returns a meshcat sphere

Return type:

Tuple[meshcat.geometry.Geometry, timor.utilities.transformation.Transformation]

timor.Geometry._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.

Parameters:

geometry_type (GeometryType) – Any of the GeometryType Enum types.

Return type:

Type[Geometry]