timor.task.Obstacle
Classes
A wrapper class to integrate hppfcl obstacles in custom Environments. |
Module Contents
- class timor.task.Obstacle.Obstacle(ID, collision, visual=None, name=None)

A wrapper class to integrate hppfcl obstacles in custom Environments.
Generate an obstacle:
- Parameters:
ID (str) – Unique identifier
collision (timor.Geometry.Geometry) – The collision geometry of the object
visual (Optional[timor.Geometry.Geometry]) – The visual geometry of the object. Defaults to the collision geometry.
name (Optional[str]) – Optional display name
- abstractmethod __copy__()
Not supported!
- __eq__(other)
Compare two obstacles by their ID, name, and geometry
- __getstate__()
Return objects which will be pickled and saved.
- __hash__()
The ID is sufficient to hash an obstacle
- __setstate__(state)
Take object from parameter and use it to retrieve class state.
- 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:
- _id = ''
- _visual = None
- collides(other)
Check if this obstacle collides with another obstacle.
Be careful, this is probably slow due to the initialisation of a new request/result pair and should only be used for debugging. Use the collision checking of the environment / robot instead.
- collision
- property display_name: str
Used for visualization and debugging. If a diplay name is explicitly given, use it, if not, it’s the ID.
- Return type:
- classmethod from_hppfcl(ID, fcl, visual_representation=None, name=None)
Create a Timor obstacle from a hppfcl obstacle
- A helper function that transforms a generic hppfcl collision object to an Obstacle with the according geometry.
(Which allows plotting, composing a task of multiple obstacles, …)
- Parameters:
ID (str) – The id that shall be given to the Obstacle.
fcl (hppfcl.hppfcl.CollisionObject) – The hppfcl collision object
visual_representation (Optional[hppfcl.hppfcl.CollisionObject]) – An optional, differing visual representation of the collision object.
name (Optional[str]) – The obstacle display name
- Returns:
An instance of the according Obstacle class, based on the kind of collision object handed over.
- Return type:
- classmethod from_json_data(d, *args, **kwargs)
Takes a json geometry specification and returns the according Obstacle.
- Parameters:
d (Dict[str, Union[str, dict]]) –
The serialized obstacle information, containing:
ID: The obstacle unique ID
collision: A Geometry used for collision detection
visual: A Geometry for visualization of this Obstacle - defaults to collision if not given
name: The obstacle display name
- Returns:
The obstacle class instance that matches the specification
- Return type:
- 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.
- mesh_material
- mesh_material_vertex_color
- to_json_data()
Interface to write a list of geometry-dictionaries that is serializable to json.
- 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.
- property visual: timor.Geometry.Geometry
Defaults to collision
- Return type:
- visualize(viz, material=None)
A custom visualization should be implemented by children.
- Parameters:
viz (pinocchio.visualize.MeshcatVisualizer) – MeshcatVisualizer to add this obstacle to.
material (Optional[meshcat.geometry.Material]) – Material to use for this obstacle; default: light red / mesh color if provided