timor.task.Constraints

Attributes

DEFAULT_CONSTRAINTS

Classes

AllGoalsFulfilled

Checks whether all goals are fulfilled

AlwaysTrueConstraint

This constraint is always true and can be used for constraints ensured by the software library before evaluation.

BasePlacement

Constraint on the placement of the base coordinate system.

CollisionFree

A constraint that checks whether the robot is in collision with the environment or itself.

ConstraintBase

Base class defining the interface all Constraints must implement.

CoterminalJointAngles

Constrains a robot can reach a certain pose, being ignorant about full circle rotation deviations

EndEffector

A constraint that checks whether the end-effector (eef) keeps a certain pose and/or velocity.

GoalOrderConstraint

Checks that the goals in the task are fulfilled in the right order.

GoalsBySameRobot

Checks that all goals specified were achieved by the same robot.

JointAngles

This is a stronger constraint than coterminal joint angles, verifying exact angles against joint limits.

JointLimits

Holds constraints on the robots (hardware) limits like position, velocity, torques, etc.

RobotConstraint

This is a mixin for constraints that can be verified given a task, a robot, and its joint positions and velocities.

SelfCollisionFree

A constraint that checks whether the robot is in collision with itself.

Module Contents

class timor.task.Constraints.AllGoalsFulfilled
Inheritance diagram of timor.task.Constraints.AllGoalsFulfilled

Checks whether all goals are fulfilled

__eq__(other)

Checks if two constraints are equal

__getstate__()

Return objects which will be pickled and saved.

__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

property _equality_parameters: Tuple[any, Ellipsis]

All goals, same constraint

Return type:

Tuple[any, Ellipsis]

classmethod _from_json_data(description, *args, **kwargs)

Default constraints can just be constructed from using json fields as constructor inputs.

Can be overwritten by children if more complex unpacking needed.

Parameters:

description (Dict[str, any])

Return type:

ConstraintBase

classmethod from_json_data(d, *args, **kwargs)

Converts a description (string, parsed from json) to a constraint

Parameters:

d (Dict[str, Any]) – A description, mapping a constraint name to one or more constraint specifications

Return type:

ConstraintBase

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)

fulfilled(solution)

Check if all goals are fulfilled by this solution.

Parameters:

solution (timor.task.Solution.SolutionBase)

Return type:

bool

global_only = True
is_valid_at(solution, t)

This constraint inherently needs access to more than one point in time

Parameters:
Return type:

bool

is_valid_until(solution, t)

Test if all goals can still be fulfilled up to time t.

Parameters:
Return type:

bool

to_json_data()

Return json-able dict of this constraint.

Return type:

Dict[str, any]

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

Return the json string representation.

Return type:

str

visualize(viz, scale=1.0, show_name=False)

Visualize the constraint in an existing meshcat window.

If possible a constraint should have a visualization. The default is no visualization and should be overwritten if a visualization is possible.

Parameters:
  • viz (pinocchio.visualize.MeshcatVisualizer) – A meshcat visualizer as defined in pinocchio

  • scale (float) – The visualization method assumes the robot size is ~1-2m maximum reach. Use the scale factor to adapt for significantly different sizes of robots and/or obstacles.

  • show_name (bool) – If True, the name of the constraint is shown in the visualization

Return type:

None

class timor.task.Constraints.AlwaysTrueConstraint
Inheritance diagram of timor.task.Constraints.AlwaysTrueConstraint

This constraint is always true and can be used for constraints ensured by the software library before evaluation.

__eq__(other)

Checks if two constraints are equal

__getstate__()

Return objects which will be pickled and saved.

__setstate__(state)

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

__slots__ = ()
_check_single_state(task, robot, q, dq, ddq)

As the name says, this constraint is always valid

Parameters:
Return type:

bool

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

property _equality_parameters: Tuple[any, Ellipsis]

Two always true constraints are always equal

Return type:

Tuple[any, Ellipsis]

classmethod _from_json_data(description, *args, **kwargs)

Default constraints can just be constructed from using json fields as constructor inputs.

Can be overwritten by children if more complex unpacking needed.

Parameters:

description (Dict[str, any])

Return type:

ConstraintBase

check_single_state(task, robot, q, dq, ddq=None)

Checks whether the constraint is fulfilled for a single state of the robot.

Parameters:
  • task (Optional[timor.task.Task.Task]) – The task that is being solved – if not provided, an empty task will be generated.

  • robot (timor.RobotBase) – The robot that is used to solve the task.

  • q (Sequence[float]) – The joint positions of the robot.

  • dq (Sequence[float]) – The joint velocities of the robot.

  • ddq (Optional[Sequence[float]]) – The joint accelerations of the robot.

Return type:

bool

classmethod from_json_data(d, *args, **kwargs)

Converts a description (string, parsed from json) to a constraint

Parameters:

d (Dict[str, Any]) – A description, mapping a constraint name to one or more constraint specifications

Return type:

ConstraintBase

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)

fulfilled(solution)

As the name says, this constraint is always valid

Parameters:

solution (timor.task.Solution.SolutionBase)

Return type:

bool

global_only: bool = False
is_valid_at(solution, t)

As the name says, this constraint is always valid

Parameters:
Return type:

bool

is_valid_until(solution, t)

As the name says, this constraint is always valid

Parameters:
Return type:

bool

to_json_data()

Dumps this constraint to a dictionary

Return type:

Dict[str, any]

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

Return the json string representation.

Return type:

str

visualize(viz, scale=1.0, show_name=False)

Visualize the constraint in an existing meshcat window.

If possible a constraint should have a visualization. The default is no visualization and should be overwritten if a visualization is possible.

Parameters:
  • viz (pinocchio.visualize.MeshcatVisualizer) – A meshcat visualizer as defined in pinocchio

  • scale (float) – The visualization method assumes the robot size is ~1-2m maximum reach. Use the scale factor to adapt for significantly different sizes of robots and/or obstacles.

  • show_name (bool) – If True, the name of the constraint is shown in the visualization

Return type:

None

class timor.task.Constraints.BasePlacement(base_pose)
Inheritance diagram of timor.task.Constraints.BasePlacement

Constraint on the placement of the base coordinate system.

Parameters:

base_pose (timor.utilities.tolerated_pose.ToleratedPose) – The desired placement of the base coordinate system with arbitrary tolerances.

__eq__(other)

Checks if two constraints are equal

__getstate__()

Return objects which will be pickled and saved.

__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

property _equality_parameters: Tuple[timor.utilities.tolerated_pose.ToleratedPose]

Equal if the placements are equal

Return type:

Tuple[timor.utilities.tolerated_pose.ToleratedPose]

classmethod _from_json_data(description, *args, **kwargs)

Create Base placement constraint from json data.

Parameters:

description (Dict[str, any])

Return type:

ConstraintBase

base_pose
classmethod from_json_data(d, *args, **kwargs)

Converts a description (string, parsed from json) to a constraint

Parameters:

d (Dict[str, Any]) – A description, mapping a constraint name to one or more constraint specifications

Return type:

ConstraintBase

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)

fulfilled(solution)

Checks whether the center of the base is within the defined tolerance.

Parameters:

solution (timor.task.Solution.SolutionBase)

Return type:

bool

global_only = True
abstractmethod is_valid_at(solution, t)

We assume the base placement does not change, so this method makes no sense.

Parameters:
Return type:

bool

is_valid_until(solution, t)

Checks that a constraint is valid on a subset of a solution until time t.

Parameters:
Return type:

bool

sample_random_valid_position()

Helps to find a valid base placement, but only works if the tolerances are not too complex.

Returns:

A valid base placement as 4x4 np array

Return type:

timor.utilities.transformation.Transformation

to_json_data()

Dumps this constraint to a dictionary

Return type:

Dict[str, any]

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

Return the json string representation.

Return type:

str

property tolerance

Utility wrapper

visualize(viz, scale=1.0, show_name=False)

Visualize the constraint

Parameters:
  • viz (pinocchio.visualize.MeshcatVisualizer)

  • scale (float)

  • show_name (bool)

Return type:

None

class timor.task.Constraints.CollisionFree(safety_margin=0)
Inheritance diagram of timor.task.Constraints.CollisionFree

A constraint that checks whether the robot is in collision with the environment or itself.

Initialize collision-free constraint

Parameters:

safety_margin (float) – A safety margin to use for collision checking. The default is 0, which means that the collision checking is done with the exact geometries. For any value larger than 0, the collision checking is done with the inflated geometries.

__eq__(other)

Checks if two constraints are equal

__getstate__()

Return objects which will be pickled and saved.

__setstate__(state)

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

__slots__ = ()
_check_single_state(task, robot, q, dq, ddq=None)

Checks the constraint for the given task in configuration q.

Parameters:
Return type:

bool

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

property _equality_parameters: Tuple[any, Ellipsis]

Collision-free is equal to itself

Return type:

Tuple[any, Ellipsis]

classmethod _from_json_data(description, *args, **kwargs)

Default constraints can just be constructed from using json fields as constructor inputs.

Can be overwritten by children if more complex unpacking needed.

Parameters:

description (Dict[str, any])

Return type:

ConstraintBase

check_single_state(task, robot, q, dq, ddq=None)

Checks whether the constraint is fulfilled for a single state of the robot.

Parameters:
  • task (Optional[timor.task.Task.Task]) – The task that is being solved – if not provided, an empty task will be generated.

  • robot (timor.RobotBase) – The robot that is used to solve the task.

  • q (Sequence[float]) – The joint positions of the robot.

  • dq (Sequence[float]) – The joint velocities of the robot.

  • ddq (Optional[Sequence[float]]) – The joint accelerations of the robot.

Return type:

bool

classmethod from_json_data(d, *args, **kwargs)

Converts a description (string, parsed from json) to a constraint

Parameters:

d (Dict[str, Any]) – A description, mapping a constraint name to one or more constraint specifications

Return type:

ConstraintBase

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)

fulfilled(solution)

Returns True iff a constraint is held over the whole solution

Parameters:

solution (timor.task.Solution.SolutionBase)

Return type:

bool

global_only: bool = False
is_valid_at(solution, t)

Checks whether the robot is in collision with the environment or itself at time t.

Parameters:
Return type:

bool

is_valid_until(solution, t)

Checks that a constraint is valid on a subset of a solution until time t.

Parameters:
Return type:

bool

safety_margin: float = 0
to_json_data()

Dumps this constraint to a dictionary

Return type:

Dict

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

Return the json string representation.

Return type:

str

visualize(viz, scale=1.0, show_name=False)

Visualize the constraint in an existing meshcat window.

If possible a constraint should have a visualization. The default is no visualization and should be overwritten if a visualization is possible.

Parameters:
  • viz (pinocchio.visualize.MeshcatVisualizer) – A meshcat visualizer as defined in pinocchio

  • scale (float) – The visualization method assumes the robot size is ~1-2m maximum reach. Use the scale factor to adapt for significantly different sizes of robots and/or obstacles.

  • show_name (bool) – If True, the name of the constraint is shown in the visualization

Return type:

None

class timor.task.Constraints.ConstraintBase
Inheritance diagram of timor.task.Constraints.ConstraintBase

Base class defining the interface all Constraints must implement.

__eq__(other)

Checks if two constraints are equal

__getstate__()

Return objects which will be pickled and saved.

__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

property _equality_parameters: Tuple[any, Ellipsis]
Abstractmethod:

Return type:

Tuple[any, Ellipsis]

Returns the parameters that should be used to check equality of constraints

classmethod _from_json_data(description, *args, **kwargs)

Default constraints can just be constructed from using json fields as constructor inputs.

Can be overwritten by children if more complex unpacking needed.

Parameters:

description (Dict[str, any])

Return type:

ConstraintBase

classmethod from_json_data(d, *args, **kwargs)

Converts a description (string, parsed from json) to a constraint

Parameters:

d (Dict[str, Any]) – A description, mapping a constraint name to one or more constraint specifications

Return type:

ConstraintBase

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)

fulfilled(solution)

Returns True iff a constraint is held over the whole solution

Parameters:

solution (timor.task.Solution.SolutionBase)

Return type:

bool

global_only: bool = False
abstractmethod is_valid_at(solution, t)

Checks that a constraint is not hurt at a specific time t

Parameters:
Return type:

bool

is_valid_until(solution, t)

Checks that a constraint is valid on a subset of a solution until time t.

Parameters:
Return type:

bool

abstractmethod to_json_data()

Should be implemented to convert the constraint to a json-serializable dictionary

Return type:

Dict[str, any]

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

Return the json string representation.

Return type:

str

visualize(viz, scale=1.0, show_name=False)

Visualize the constraint in an existing meshcat window.

If possible a constraint should have a visualization. The default is no visualization and should be overwritten if a visualization is possible.

Parameters:
  • viz (pinocchio.visualize.MeshcatVisualizer) – A meshcat visualizer as defined in pinocchio

  • scale (float) – The visualization method assumes the robot size is ~1-2m maximum reach. Use the scale factor to adapt for significantly different sizes of robots and/or obstacles.

  • show_name (bool) – If True, the name of the constraint is shown in the visualization

Return type:

None

class timor.task.Constraints.CoterminalJointAngles(limits)
Inheritance diagram of timor.task.Constraints.CoterminalJointAngles

Constrains a robot can reach a certain pose, being ignorant about full circle rotation deviations

This constraint checks whether given joint position, given by joint angles, can be reached in general. It does not check for the exact joint angles but for their coterminal counterpart in the range [-pi, pi)

Parameters:

limits (numpy.ndarray) – A 2xdof array of joint limits: [[lower_limits], [upper_limimts]]

__eq__(other)

Checks if two constraints are equal

__getstate__()

Return objects which will be pickled and saved.

__setstate__(state)

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

__slots__ = ()
_check_single_state(task, robot, q, dq, ddq=None)

Checks if q is within the joint limits, ignoring all other arguments.

Parameters:
Return type:

bool

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

property _equality_parameters: Tuple[float, Ellipsis]

Flatten the limits to a 1d array

Return type:

Tuple[float, Ellipsis]

classmethod _from_json_data(description, *args, **kwargs)

Default constraints can just be constructed from using json fields as constructor inputs.

Can be overwritten by children if more complex unpacking needed.

Parameters:

description (Dict[str, any])

Return type:

ConstraintBase

_validate(q)

Returns whether q is within the joint limits

Parameters:

q (numpy.ndarray) – Joint angles in the interval [-pi, pi)

Return type:

bool

check_single_state(task, robot, q, dq, ddq=None)

Checks whether the constraint is fulfilled for a single state of the robot.

Parameters:
  • task (Optional[timor.task.Task.Task]) – The task that is being solved – if not provided, an empty task will be generated.

  • robot (timor.RobotBase) – The robot that is used to solve the task.

  • q (Sequence[float]) – The joint positions of the robot.

  • dq (Sequence[float]) – The joint velocities of the robot.

  • ddq (Optional[Sequence[float]]) – The joint accelerations of the robot.

Return type:

bool

classmethod from_json_data(d, *args, **kwargs)

Converts a description (string, parsed from json) to a constraint

Parameters:

d (Dict[str, Any]) – A description, mapping a constraint name to one or more constraint specifications

Return type:

ConstraintBase

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)

fulfilled(solution)

Returns True iff a constraint is held over the whole solution

Parameters:

solution (timor.task.Solution.SolutionBase)

Return type:

bool

global_only: bool = False
is_valid_at(solution, t)

Checks whether the given joint angles are within the defined limits at time t.

Parameters:
Return type:

bool

is_valid_until(solution, t)

Checks that a constraint is valid on a subset of a solution until time t.

Parameters:
Return type:

bool

limits
static map(q)

Maps the input q to the range [-pi, pi).

Parameters:

q (Union[float, numpy.ndarray])

Return type:

Union[float, numpy.ndarray]

abstractmethod to_json_data()

Dumps this constraint to a dictionary

Return type:

Dict[str, any]

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

Return the json string representation.

Return type:

str

visualize(viz, scale=1.0, show_name=False)

Visualize the constraint in an existing meshcat window.

If possible a constraint should have a visualization. The default is no visualization and should be overwritten if a visualization is possible.

Parameters:
  • viz (pinocchio.visualize.MeshcatVisualizer) – A meshcat visualizer as defined in pinocchio

  • scale (float) – The visualization method assumes the robot size is ~1-2m maximum reach. Use the scale factor to adapt for significantly different sizes of robots and/or obstacles.

  • show_name (bool) – If True, the name of the constraint is shown in the visualization

Return type:

None

timor.task.Constraints.DEFAULT_CONSTRAINTS
class timor.task.Constraints.EndEffector(*, pose=None, velocity_lim=None, rotation_velocity_lim=None)
Inheritance diagram of timor.task.Constraints.EndEffector

A constraint that checks whether the end-effector (eef) keeps a certain pose and/or velocity.

Initialize eef constraint.

Parameters:
  • pose (Optional[timor.utilities.tolerated_pose.ToleratedPose]) – tolerated pose to keep within (either initialized or serialized in dict)

  • velocity_lim (Optional[numpy.ndarray]) – Minimal / Maximal translation velocity \(v\) of the end-effector in \(\frac{m}{s}\); defaults to any allowed

  • rotation_velocity_lim (Optional[numpy.ndarray]) – Minimal / Maximal rotation velocity \(\omega\) of the end-effector in \(\frac{rad}{s}\); defaults to any allowed

__eq__(other)

Checks if two constraints are equal

__getstate__()

Return objects which will be pickled and saved.

__setstate__(state)

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

__slots__ = ()
_check_single_state(task, robot, q, dq, ddq=None)

Can be used to check this constraint against a single, existing robot state. The task is ignored.

Parameters:
Return type:

bool

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

property _equality_parameters: Tuple[any, Ellipsis]

End-effector constraints are equal if they have the same pose and limits

Return type:

Tuple[any, Ellipsis]

classmethod _from_json_data(description, *args, **kwargs)

Default constraints can just be constructed from using json fields as constructor inputs.

Can be overwritten by children if more complex unpacking needed.

Parameters:

description (Dict[str, any])

Return type:

ConstraintBase

check_single_state(task, robot, q, dq, ddq=None)

Checks whether the constraint is fulfilled for a single state of the robot.

Parameters:
  • task (Optional[timor.task.Task.Task]) – The task that is being solved – if not provided, an empty task will be generated.

  • robot (timor.RobotBase) – The robot that is used to solve the task.

  • q (Sequence[float]) – The joint positions of the robot.

  • dq (Sequence[float]) – The joint velocities of the robot.

  • ddq (Optional[Sequence[float]]) – The joint accelerations of the robot.

Return type:

bool

default_velocity_limits
classmethod from_json_data(d, *args, **kwargs)

Converts a description (string, parsed from json) to a constraint

Parameters:

d (Dict[str, Any]) – A description, mapping a constraint name to one or more constraint specifications

Return type:

ConstraintBase

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)

fulfilled(solution)

Returns True iff a constraint is held over the whole solution

Parameters:

solution (timor.task.Solution.SolutionBase)

Return type:

bool

global_only: bool = False
is_valid_at(solution, t)

Checks whether the robot obeys eef velocity and pose constraints at time t.

Parameters:
Return type:

bool

is_valid_until(solution, t)

Checks that a constraint is valid on a subset of a solution until time t.

Parameters:
Return type:

bool

pose: timor.utilities.tolerated_pose.ToleratedPose | None = None
rotation_velocity_lim: numpy.ndarray | None
to_json_data()

Dumps this constraint to a dictionary.

Return type:

Dict[str, any]

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

Return the json string representation.

Return type:

str

velocity_lim: numpy.ndarray | None
visualize(viz, scale=1.0, show_name=False)

Visualize the constraint in an existing meshcat window.

If possible a constraint should have a visualization. The default is no visualization and should be overwritten if a visualization is possible.

Parameters:
  • viz (pinocchio.visualize.MeshcatVisualizer) – A meshcat visualizer as defined in pinocchio

  • scale (float) – The visualization method assumes the robot size is ~1-2m maximum reach. Use the scale factor to adapt for significantly different sizes of robots and/or obstacles.

  • show_name (bool) – If True, the name of the constraint is shown in the visualization

Return type:

None

class timor.task.Constraints.GoalOrderConstraint(order)
Inheritance diagram of timor.task.Constraints.GoalOrderConstraint

Checks that the goals in the task are fulfilled in the right order.

Parameters:

order (Iterable[str]) – An iterable of goal IDs that defines the order in which they should be achieved

__eq__(other)

Checks if two constraints are equal

__getstate__()

Return objects which will be pickled and saved.

__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

property _equality_parameters: Tuple[str, Ellipsis]

Same order, same constraint

Return type:

Tuple[str, Ellipsis]

classmethod _from_json_data(description, *args, **kwargs)

Default constraints can just be constructed from using json fields as constructor inputs.

Can be overwritten by children if more complex unpacking needed.

Parameters:

description (Dict[str, any])

Return type:

ConstraintBase

classmethod from_json_data(d, *args, **kwargs)

Converts a description (string, parsed from json) to a constraint

Parameters:

d (Dict[str, Any]) – A description, mapping a constraint name to one or more constraint specifications

Return type:

ConstraintBase

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)

fulfilled(solution)

Every goal specified by this constraint must be fulfilled in the right order

Parameters:

solution (timor.task.Solution.SolutionBase)

Return type:

bool

global_only = True
is_valid_at(solution, t)

This constraint inherently needs access to more than one point in time

Parameters:
Return type:

bool

is_valid_until(solution, t)

Evaluates the solution up to time t

Parameters:
Return type:

bool

order: Tuple[str, Ellipsis]
to_json_data()

Dumps this constraint to a dictionary

Return type:

Dict[str, any]

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

Return the json string representation.

Return type:

str

visualize(viz, scale=1.0, show_name=False)

Visualize the constraint in an existing meshcat window.

If possible a constraint should have a visualization. The default is no visualization and should be overwritten if a visualization is possible.

Parameters:
  • viz (pinocchio.visualize.MeshcatVisualizer) – A meshcat visualizer as defined in pinocchio

  • scale (float) – The visualization method assumes the robot size is ~1-2m maximum reach. Use the scale factor to adapt for significantly different sizes of robots and/or obstacles.

  • show_name (bool) – If True, the name of the constraint is shown in the visualization

Return type:

None

class timor.task.Constraints.GoalsBySameRobot(goals)
Inheritance diagram of timor.task.Constraints.GoalsBySameRobot

Checks that all goals specified were achieved by the same robot.

Parameters:

goals (Iterable[str]) – The goals that need to be achieved by the same robot

__eq__(other)

Checks if two constraints are equal

__getstate__()

Return objects which will be pickled and saved.

__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

property _equality_parameters: Tuple[str, Ellipsis]

Same goals, same constraint

Return type:

Tuple[str, Ellipsis]

classmethod _from_json_data(description, *args, **kwargs)

Default constraints can just be constructed from using json fields as constructor inputs.

Can be overwritten by children if more complex unpacking needed.

Parameters:

description (Dict[str, any])

Return type:

ConstraintBase

classmethod from_json_data(d, *args, **kwargs)

Converts a description (string, parsed from json) to a constraint

Parameters:

d (Dict[str, Any]) – A description, mapping a constraint name to one or more constraint specifications

Return type:

ConstraintBase

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)

fulfilled(solution)

Returns True iff a constraint is held over the whole solution

Parameters:

solution (timor.task.Solution.SolutionBase)

Return type:

bool

global_only = True
goals
is_valid_at(solution, t)

This constraint inherently needs access to more than one point in time

Parameters:
Return type:

bool

abstractmethod is_valid_until(solution, t)

Evaluates the solution up to time t

Parameters:
Return type:

bool

to_json_data()

Dumps this constraint to a dictionary

Return type:

Dict[str, any]

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

Return the json string representation.

Return type:

str

visualize(viz, scale=1.0, show_name=False)

Visualize the constraint in an existing meshcat window.

If possible a constraint should have a visualization. The default is no visualization and should be overwritten if a visualization is possible.

Parameters:
  • viz (pinocchio.visualize.MeshcatVisualizer) – A meshcat visualizer as defined in pinocchio

  • scale (float) – The visualization method assumes the robot size is ~1-2m maximum reach. Use the scale factor to adapt for significantly different sizes of robots and/or obstacles.

  • show_name (bool) – If True, the name of the constraint is shown in the visualization

Return type:

None

class timor.task.Constraints.JointAngles(limits)
Inheritance diagram of timor.task.Constraints.JointAngles

This is a stronger constraint than coterminal joint angles, verifying exact angles against joint limits.

limits: A 2xdof array of joint limits: [[lower_limits], [upper_limimts]]

Parameters:

limits (numpy.ndarray)

__eq__(other)

Checks if two constraints are equal

__getstate__()

Return objects which will be pickled and saved.

__setstate__(state)

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

__slots__ = ()
_check_single_state(task, robot, q, dq, ddq=None)

Checks if q is within the joint limits, ignoring all other arguments.

Parameters:
Return type:

bool

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

property _equality_parameters: Tuple[float, Ellipsis]

Flatten the limits to a 1d array

Return type:

Tuple[float, Ellipsis]

classmethod _from_json_data(description, *args, **kwargs)

Default constraints can just be constructed from using json fields as constructor inputs.

Can be overwritten by children if more complex unpacking needed.

Parameters:

description (Dict[str, any])

Return type:

ConstraintBase

_validate(q)

Returns whether q is within the joint limits

Parameters:

q (numpy.ndarray) – Joint angles in the interval [-pi, pi)

Return type:

bool

check_single_state(task, robot, q, dq, ddq=None)

Checks whether the constraint is fulfilled for a single state of the robot.

Parameters:
  • task (Optional[timor.task.Task.Task]) – The task that is being solved – if not provided, an empty task will be generated.

  • robot (timor.RobotBase) – The robot that is used to solve the task.

  • q (Sequence[float]) – The joint positions of the robot.

  • dq (Sequence[float]) – The joint velocities of the robot.

  • ddq (Optional[Sequence[float]]) – The joint accelerations of the robot.

Return type:

bool

classmethod from_json_data(d, *args, **kwargs)

Converts a description (string, parsed from json) to a constraint

Parameters:

d (Dict[str, Any]) – A description, mapping a constraint name to one or more constraint specifications

Return type:

ConstraintBase

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)

fulfilled(solution)

Returns True iff a constraint is held over the whole solution

Parameters:

solution (timor.task.Solution.SolutionBase)

Return type:

bool

global_only: bool = False
is_valid_at(solution, t)

Checks whether the given joint angles are within the defined limits at time t.

Parameters:
Return type:

bool

is_valid_until(solution, t)

Checks that a constraint is valid on a subset of a solution until time t.

Parameters:
Return type:

bool

limits
static map(q)

Overwrites the mapping to the interval [-pi, pi) s.t. the original angles are checked.

Parameters:

q (Union[float, numpy.ndarray])

Return type:

Union[float, numpy.ndarray]

abstractmethod to_json_data()

Dumps this constraint to a dictionary

Return type:

Dict[str, any]

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

Return the json string representation.

Return type:

str

visualize(viz, scale=1.0, show_name=False)

Visualize the constraint in an existing meshcat window.

If possible a constraint should have a visualization. The default is no visualization and should be overwritten if a visualization is possible.

Parameters:
  • viz (pinocchio.visualize.MeshcatVisualizer) – A meshcat visualizer as defined in pinocchio

  • scale (float) – The visualization method assumes the robot size is ~1-2m maximum reach. Use the scale factor to adapt for significantly different sizes of robots and/or obstacles.

  • show_name (bool) – If True, the name of the constraint is shown in the visualization

Return type:

None

class timor.task.Constraints.JointLimits(parts)
Inheritance diagram of timor.task.Constraints.JointLimits

Holds constraints on the robots (hardware) limits like position, velocity, torques, etc.

Builds the joint limit constraint

Parameters:

parts (Iterable[str]) – Can be any of (q, dq, ddq, tau) and define what is constrained

__eq__(other)

Checks if two constraints are equal

__getstate__()

Return objects which will be pickled and saved.

__setstate__(state)

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

__slots__ = ()
_check_single_state(task, robot, q, dq, ddq=None)

Checks whether the limits of the robot are held.

As a single state doesn’t have a solution reference, this check assumes no external influences. :param task: The task is not being used in this check. :param robot: The robot for which the limits are checked. :param q: The joint positions of the robot. :param dq: The joint velocities of the robot. :param ddq: The joint accelerations of the robot.

Parameters:
Return type:

bool

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

property _equality_parameters: Tuple[str, Ellipsis]

Same parts, same constraint

Return type:

Tuple[str, Ellipsis]

classmethod _from_json_data(description, *args, **kwargs)

Default constraints can just be constructed from using json fields as constructor inputs.

Can be overwritten by children if more complex unpacking needed.

Parameters:

description (Dict[str, any])

Return type:

ConstraintBase

_robot_attributs = ('joint_limits', 'joint_velocity_limits', 'joint_acceleration_limits', 'joint_torque_limits')
check_single_state(task, robot, q, dq, ddq=None)

Checks whether the constraint is fulfilled for a single state of the robot.

Parameters:
  • task (Optional[timor.task.Task.Task]) – The task that is being solved – if not provided, an empty task will be generated.

  • robot (timor.RobotBase) – The robot that is used to solve the task.

  • q (Sequence[float]) – The joint positions of the robot.

  • dq (Sequence[float]) – The joint velocities of the robot.

  • ddq (Optional[Sequence[float]]) – The joint accelerations of the robot.

Return type:

bool

ddq
dq
classmethod from_json_data(d, *args, **kwargs)

Converts a description (string, parsed from json) to a constraint

Parameters:

d (Dict[str, Any]) – A description, mapping a constraint name to one or more constraint specifications

Return type:

ConstraintBase

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)

fulfilled(solution)

Returns True iff a constraint is held over the whole solution

Parameters:

solution (timor.task.Solution.SolutionBase)

Return type:

bool

global_only: bool = False
is_valid_at(solution, t)

Evaluates the solution at time t

Parameters:
Return type:

bool

is_valid_until(solution, t)

Evaluates the solution up to time t

Parameters:
Return type:

bool

q
robot_limit_types = ('q', 'dq', 'ddq', 'tau')
tau
to_json_data()

Dumps this constraint to a dictionary

Return type:

Dict[str, any]

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

Return the json string representation.

Return type:

str

visualize(viz, scale=1.0, show_name=False)

Visualize the constraint in an existing meshcat window.

If possible a constraint should have a visualization. The default is no visualization and should be overwritten if a visualization is possible.

Parameters:
  • viz (pinocchio.visualize.MeshcatVisualizer) – A meshcat visualizer as defined in pinocchio

  • scale (float) – The visualization method assumes the robot size is ~1-2m maximum reach. Use the scale factor to adapt for significantly different sizes of robots and/or obstacles.

  • show_name (bool) – If True, the name of the constraint is shown in the visualization

Return type:

None

class timor.task.Constraints.RobotConstraint
Inheritance diagram of timor.task.Constraints.RobotConstraint

This is a mixin for constraints that can be verified given a task, a robot, and its joint positions and velocities.

They are not necessarily to be used only in tasks, but can be used to check whether a robot is in a valid state for downstream tasks like the computation of the inverse kinematics.

__slots__ = ()
abstractmethod _check_single_state(task, robot, q, dq, ddq=None)

This method needs to be implemented by all constraints that inherit from this mixin.

Parameters:
Return type:

bool

check_single_state(task, robot, q, dq, ddq=None)

Checks whether the constraint is fulfilled for a single state of the robot.

Parameters:
  • task (Optional[timor.task.Task.Task]) – The task that is being solved – if not provided, an empty task will be generated.

  • robot (timor.RobotBase) – The robot that is used to solve the task.

  • q (Sequence[float]) – The joint positions of the robot.

  • dq (Sequence[float]) – The joint velocities of the robot.

  • ddq (Optional[Sequence[float]]) – The joint accelerations of the robot.

Return type:

bool

class timor.task.Constraints.SelfCollisionFree(safety_margin=0)
Inheritance diagram of timor.task.Constraints.SelfCollisionFree

A constraint that checks whether the robot is in collision with itself.

Initialize self-collision-free constraint

Parameters:

safety_margin (float) – For self collisions, this parameter is currently ignored.

__eq__(other)

Checks if two constraints are equal

__getstate__()

Return objects which will be pickled and saved.

__setstate__(state)

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

__slots__ = ()
_check_single_state(task, robot, q, dq, ddq=None)

Checks the constraint for the given task in configuration q.

Parameters:
Return type:

bool

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

property _equality_parameters: Tuple[any, Ellipsis]

Collision-free is equal to itself

Return type:

Tuple[any, Ellipsis]

classmethod _from_json_data(description, *args, **kwargs)

Default constraints can just be constructed from using json fields as constructor inputs.

Can be overwritten by children if more complex unpacking needed.

Parameters:

description (Dict[str, any])

Return type:

ConstraintBase

check_single_state(task, robot, q, dq, ddq=None)

Checks whether the constraint is fulfilled for a single state of the robot.

Parameters:
  • task (Optional[timor.task.Task.Task]) – The task that is being solved – if not provided, an empty task will be generated.

  • robot (timor.RobotBase) – The robot that is used to solve the task.

  • q (Sequence[float]) – The joint positions of the robot.

  • dq (Sequence[float]) – The joint velocities of the robot.

  • ddq (Optional[Sequence[float]]) – The joint accelerations of the robot.

Return type:

bool

classmethod from_json_data(d, *args, **kwargs)

Converts a description (string, parsed from json) to a constraint

Parameters:

d (Dict[str, Any]) – A description, mapping a constraint name to one or more constraint specifications

Return type:

ConstraintBase

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)

fulfilled(solution)

Returns True iff a constraint is held over the whole solution

Parameters:

solution (timor.task.Solution.SolutionBase)

Return type:

bool

global_only: bool = False
is_valid_at(solution, t)

Checks whether the robot is in collision with the environment or itself at time t.

Parameters:
Return type:

bool

is_valid_until(solution, t)

Checks that a constraint is valid on a subset of a solution until time t.

Parameters:
Return type:

bool

safety_margin: float = 0
to_json_data()

Dumps this constraint to a dictionary

Return type:

Dict[str, any]

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

Return the json string representation.

Return type:

str

visualize(viz, scale=1.0, show_name=False)

Visualize the constraint in an existing meshcat window.

If possible a constraint should have a visualization. The default is no visualization and should be overwritten if a visualization is possible.

Parameters:
  • viz (pinocchio.visualize.MeshcatVisualizer) – A meshcat visualizer as defined in pinocchio

  • scale (float) – The visualization method assumes the robot size is ~1-2m maximum reach. Use the scale factor to adapt for significantly different sizes of robots and/or obstacles.

  • show_name (bool) – If True, the name of the constraint is shown in the visualization

Return type:

None