timor.task.Task
Attributes
Classes
A task describes a problem that must be solved by one or multiple robots. |
|
The header every task contains |
Module Contents
- timor.task.Task.GRAVITY
- class timor.task.Task.Task(header, obstacles=None, goals=None, constraints=None, frames=None)

A task describes a problem that must be solved by one or multiple robots.
The problem can be composed of multiple goals, each with their own constraints. Global constraints, e.g. valid base placements or the order of goals can be defined on the task-level.
Create a Task:
- Parameters:
header (Union[TaskHeader, Dict]) – The header contains meta informaton about the task. Must at least contain an ID.
obstacles (Collection[timor.task.Obstacle.Obstacle]) – Obstacles in the task/environment the robots should not collide with.
goals (Sequence[timor.task.Goals.GoalBase]) – The complete set of goals that need to be achieved in order to solve the task
constraints (Optional[Collection[timor.task.Constraints.ConstraintBase]]) – “Global” constraint that must hold for the whole task.
frames (timor.utilities.frames.FrameTree)
- __deepcopy__(memodict={})
Custom deepcopy for the task class. Experimental!
- __eq__(other)
Tasks are equal if headers, goals, constraints, and obstacles are equal.
- __getstate__()
Return objects which will be pickled and saved.
- __hash__()
Hash is given by the unique ID.
- __repr__()
Debug representation of a task.
- __setstate__(state)
Take object from parameter and use it to retrieve class state.
- static _deduce_package_dir(filepath, content)
Deduce the package directory from the filepath and the content of the task.
A task is always stored in <package_dir>/<task.id>.json. The package_dir is the directory; the task.id may also contain subdirectories / namespacing denoted with “/”.
- Parameters:
filepath (pathlib.Path) – The path to the task file
content (Union[Dict, List]) – The content of the task file
- Return type:
return: The package directory that all file keys in content are relative to.
- add_obstacle(obstacle)
Adds an obstacle to the existing task.
- Parameters:
obstacle (timor.task.Obstacle.Obstacle) – Any obstacle derived from the Obstacle class. This can contain a single geometry or compositions of such.
- property base_constraint: timor.task.Constraints.BasePlacement
Returns the base constraint of this task.
- Raise:
AttributeError if not BasePlacement Constraint given.
- Return type:
- property collision_objects: Tuple[hppfcl.hppfcl.CollisionObject, Ellipsis]
All hppfcl collision objects by obstacles in the task
- Return type:
Tuple[hppfcl.hppfcl.CollisionObject, Ellipsis]
- constraints: Tuple[timor.task.Constraints.ConstraintBase]
- frames = None
- classmethod from_id(id, package_dir)
Load a task based on its id stored in package_dir/id.json.
- Parameters:
id (str) – id (including namespace with “/” to look for.
package_dir (pathlib.Path) – The directory to look for the task in.
- Return type:
- classmethod from_json_data(d, *args, **kwargs)
Loads a task from a parsed json (=dictionary).
- Parameters:
d (Dict[str, any]) – The parsed json data
- 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.
- static from_srf_file(filepath)
- Abstractmethod:
- Parameters:
filepath (pathlib.Path)
Future Work
- goals: Tuple[timor.task.Goals.GoalBase] = ()
- property goals_by_id: Dict[str, timor.task.Goals.GoalBase]
Return a mapping from all goal ID’s to their python instances
- Return type:
Dict[str, timor.task.Goals.GoalBase]
- header
- property obstacle_names: Tuple[str, Ellipsis]
Returns the names of all obstacles in the task
- Return type:
Tuple[str, Ellipsis]
- obstacles: List[timor.task.Obstacle.Obstacle] = []
- to_json_file(save_at, handle_missing_assets=None, *args, **kwargs)
Save the task to a json file.
- Parameters:
save_at (Union[pathlib.Path, str]) – The path to save the task to. If it is a directory, the task will be saved to save_at/<task.id>.json. If it is a file, the task will be saved to save_at and it is ensured that the filename ends in <task.id>.json.
handle_missing_assets (Optional[str]) – How to handle missing assets. See
timor.utilities.helper.handle_assets()for details.
- visualize(viz=None, robots=None, show_obstacle=True, show_goals=True, show_constraints=True, show_frames=False, show_names=False, center_view=True)
Plots the task in a Meshcat visualizer.
Calls the “visualize” function for each Object, Robot, Goal and Constraint in the task. As Objects are the high-level representation of “things” in the Environment, this visualization function uses their high-level plotting functionalities, so visual meshes etc. will be chosen if available.
- Parameters:
viz (pinocchio.visualize.MeshcatVisualizer) – MeshcatViusalizer to work in; default: create new one
robots (Optional[robot_or_robots]) – Robots to be visualized
show_obstacle (bool) – bool to turn on obstacle rendering (default true)
show_goals (bool) – bool to turn on goal rendering (default true)
show_constraints (bool) – bool to turn on constraint rendering for those that can be displayed (default true)
show_frames (bool) – bool to turn on frame rendering (default true)
show_names (bool) – bool to turn on name rendering, e.g., for goals (default false)
center_view (bool) – if set to true try to find a reasonable camera position such that task visible, i.e. try to center camera on the first robot’s base and if that is not set try to center the base constraint pose.
- Return type:
pinocchio.visualize.MeshcatVisualizer
- class timor.task.Task.TaskHeader

The header every task contains
- __delattr__(item)
Delete attribute
- __eq__(other)
Equality of headers is given by equality of attributes
- __post_init__()
Post init function that ensures the correct datatypes
- __setattr__(key, value)
Sets an attribute of this class
- _raise_immutable(f)
Raises error if objects in this dataclass are to be resetted but the instance is set to immutable
- Parameters:
f (Callable)
- Return type:
Callable
- static cast(value, cast_to_type)
Casts the value to the dtype
- Parameters:
value (Any)
cast_to_type (Type)
- Return type:
Any
- static cast_to_date(value)
Casts the value to a datetime.date object
- Parameters:
value (Union[str, datetime.date, datetime.datetime])
- Return type:
- date: datetime.date
- classmethod empty()
Returns an empty task header
- Return type:
- gravity: numpy.ndarray
- static string_list_factory()
Returns a field with a default factory that returns a list with one empty string
- Return type:
dataclasses.field
- tags: List = []
- timor.task.Task.robot_or_robots