timor.task.Task

Attributes

GRAVITY

robot_or_robots

Classes

Task

A task describes a problem that must be solved by one or multiple robots.

TaskHeader

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)
Inheritance diagram of timor.task.Task.Task

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

pathlib.Path

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:

timor.task.Constraints.BasePlacement

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]
classmethod empty()

Returns an empty task with an empty header

Return type:

Task

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:

Task

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.

classmethod from_json_string(s, *args, **kwargs)

Create from a json string.

Parameters:

s (str)

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 id: str

The unique ID of the task

Return type:

str

property name: str

Returns the task ID, use not recommended

Return type:

str

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_data()

Returns the serialized task dictionary

Return type:

Dict[str, any]

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.

to_json_string()

Return the json string representation.

Return type:

str

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
Inheritance diagram of timor.task.Task.TaskHeader

The header every task contains

ID: str
__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

affiliation: List[str]
asdict()

Returns a dictionary representation of this object

Return type:

Dict[str, Any]

author: List[str]
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:

datetime.date

date: datetime.date
email: List[str]
classmethod empty()

Returns an empty task header

Return type:

TaskHeader

classmethod fields()

Returns the fields of this class

Return type:

Tuple[str, Ellipsis]

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 = []
taskName: str = ''
timeStepSize: float = 0.01
version: str = '2023'
timor.task.Task.robot_or_robots