timor.task.Constraints
Attributes
Classes
Checks whether all goals are fulfilled |
|
This constraint is always true and can be used for constraints ensured by the software library before evaluation. |
|
Constraint on the placement of the base coordinate system. |
|
A constraint that checks whether the robot is in collision with the environment or itself. |
|
Base class defining the interface all Constraints must implement. |
|
Constrains a robot can reach a certain pose, being ignorant about full circle rotation deviations |
|
A constraint that checks whether the end-effector (eef) keeps a certain pose and/or velocity. |
|
Checks that the goals in the task are fulfilled in the right order. |
|
Checks that all goals specified were achieved by the same robot. |
|
This is a stronger constraint than coterminal joint angles, verifying exact angles against joint limits. |
|
Holds constraints on the robots (hardware) limits like position, velocity, torques, etc. |
|
This is a mixin for constraints that can be verified given a task, a robot, and its joint positions and velocities. |
|
A constraint that checks whether the robot is in collision with itself. |
Module Contents
- class 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:
- 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:
- 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:
- 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.
- fulfilled(solution)
Check if all goals are fulfilled by this solution.
- Parameters:
solution (timor.task.Solution.SolutionBase)
- Return type:
- global_only = True
- is_valid_at(solution, t)
This constraint inherently needs access to more than one point in time
- Parameters:
solution (timor.task.Solution.SolutionBase)
t (float)
- Return type:
- is_valid_until(solution, t)
Test if all goals can still be fulfilled up to time t.
- Parameters:
solution (timor.task.Solution.SolutionBase)
t (float)
- Return type:
- 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.
- 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

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:
task (Optional[timor.task.Task.Task])
robot (timor.RobotBase)
q (numpy.ndarray)
dq (numpy.ndarray)
ddq (Optional[numpy.ndarray])
- Return type:
- 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:
- 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:
- 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:
- 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:
- 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.
- fulfilled(solution)
As the name says, this constraint is always valid
- Parameters:
solution (timor.task.Solution.SolutionBase)
- Return type:
- is_valid_at(solution, t)
As the name says, this constraint is always valid
- Parameters:
solution (timor.task.Solution.SolutionBase)
t (float)
- Return type:
- is_valid_until(solution, t)
As the name says, this constraint is always valid
- Parameters:
solution (timor.task.Solution.SolutionBase)
t (float)
- Return type:
- 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.
- 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)

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:
- property _equality_parameters: Tuple[timor.utilities.tolerated_pose.ToleratedPose]
Equal if the placements are equal
- Return type:
- classmethod _from_json_data(description, *args, **kwargs)
Create Base placement constraint from json data.
- Parameters:
description (Dict[str, any])
- Return type:
- 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:
- 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.
- fulfilled(solution)
Checks whether the center of the base is within the defined tolerance.
- Parameters:
solution (timor.task.Solution.SolutionBase)
- Return type:
- global_only = True
- abstractmethod is_valid_at(solution, t)
We assume the base placement does not change, so this method makes no sense.
- Parameters:
solution (timor.task.Solution.SolutionBase)
t (float)
- Return type:
- is_valid_until(solution, t)
Checks that a constraint is valid on a subset of a solution until time t.
- Parameters:
solution (timor.task.Solution.SolutionBase)
t (float)
- Return type:
- 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:
- 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 tolerance
Utility wrapper
- class timor.task.Constraints.CollisionFree(safety_margin=0)

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:
task (Optional[timor.task.Task.Task])
robot (timor.RobotBase)
q (numpy.ndarray)
dq (numpy.ndarray)
ddq (Optional[numpy.ndarray])
- Return type:
- 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:
- 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:
- 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:
- 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:
- 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.
- fulfilled(solution)
Returns True iff a constraint is held over the whole solution
- Parameters:
solution (timor.task.Solution.SolutionBase)
- Return type:
- is_valid_at(solution, t)
Checks whether the robot is in collision with the environment or itself at time t.
- Parameters:
solution (timor.task.Solution.SolutionBase)
t (float)
- Return type:
- is_valid_until(solution, t)
Checks that a constraint is valid on a subset of a solution until time t.
- Parameters:
solution (timor.task.Solution.SolutionBase)
t (float)
- Return type:
- 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.
- 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

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:
- 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:
- 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:
- 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.
- fulfilled(solution)
Returns True iff a constraint is held over the whole solution
- Parameters:
solution (timor.task.Solution.SolutionBase)
- Return type:
- abstractmethod is_valid_at(solution, t)
Checks that a constraint is not hurt at a specific time t
- Parameters:
solution (timor.task.Solution.SolutionBase)
t (float)
- Return type:
- is_valid_until(solution, t)
Checks that a constraint is valid on a subset of a solution until time t.
- Parameters:
solution (timor.task.Solution.SolutionBase)
t (float)
- Return type:
- 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.
- 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)

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:
task (Optional[timor.task.Task.Task])
robot (timor.RobotBase)
q (numpy.ndarray)
dq (numpy.ndarray)
ddq (Optional[numpy.ndarray])
- Return type:
- 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:
- 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:
- _validate(q)
Returns whether q is within the joint limits
- Parameters:
q (numpy.ndarray) – Joint angles in the interval [-pi, pi)
- Return type:
- 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:
- 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:
- 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.
- fulfilled(solution)
Returns True iff a constraint is held over the whole solution
- Parameters:
solution (timor.task.Solution.SolutionBase)
- Return type:
- is_valid_at(solution, t)
Checks whether the given joint angles are within the defined limits at time t.
- Parameters:
solution (timor.task.Solution.SolutionBase)
t (float)
- Return type:
- is_valid_until(solution, t)
Checks that a constraint is valid on a subset of a solution until time t.
- Parameters:
solution (timor.task.Solution.SolutionBase)
t (float)
- Return type:
- 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]
- 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.
- 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)

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:
task (timor.task.Task)
robot (timor.RobotBase)
q (numpy.ndarray)
dq (numpy.ndarray)
ddq (Optional[numpy.ndarray])
- Return type:
- 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:
- 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:
- 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:
- 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:
- 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.
- fulfilled(solution)
Returns True iff a constraint is held over the whole solution
- Parameters:
solution (timor.task.Solution.SolutionBase)
- Return type:
- is_valid_at(solution, t)
Checks whether the robot obeys eef velocity and pose constraints at time t.
- Parameters:
solution (timor.task.Solution.SolutionBase)
t (float)
- Return type:
- is_valid_until(solution, t)
Checks that a constraint is valid on a subset of a solution until time t.
- Parameters:
solution (timor.task.Solution.SolutionBase)
t (float)
- Return type:
- pose: timor.utilities.tolerated_pose.ToleratedPose | None = None
- rotation_velocity_lim: numpy.ndarray | None
- 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.
- 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)

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:
- 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:
- 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:
- 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.
- fulfilled(solution)
Every goal specified by this constraint must be fulfilled in the right order
- Parameters:
solution (timor.task.Solution.SolutionBase)
- Return type:
- global_only = True
- is_valid_at(solution, t)
This constraint inherently needs access to more than one point in time
- Parameters:
solution (timor.task.Solution.SolutionBase)
t (float)
- Return type:
- is_valid_until(solution, t)
Evaluates the solution up to time t
- Parameters:
solution (timor.task.Solution.SolutionBase)
t (float)
- Return type:
- 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.
- 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)

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:
- 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:
- 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:
- 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.
- fulfilled(solution)
Returns True iff a constraint is held over the whole solution
- Parameters:
solution (timor.task.Solution.SolutionBase)
- Return type:
- global_only = True
- goals
- is_valid_at(solution, t)
This constraint inherently needs access to more than one point in time
- Parameters:
solution (timor.task.Solution.SolutionBase)
t (float)
- Return type:
- abstractmethod is_valid_until(solution, t)
Evaluates the solution up to time t
- Parameters:
solution (timor.task.Solution.SolutionBase)
t (float)
- Return type:
- 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.
- 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)

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:
task (Optional[timor.task.Task.Task])
robot (timor.RobotBase)
q (numpy.ndarray)
dq (numpy.ndarray)
ddq (Optional[numpy.ndarray])
- Return type:
- 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:
- 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:
- _validate(q)
Returns whether q is within the joint limits
- Parameters:
q (numpy.ndarray) – Joint angles in the interval [-pi, pi)
- Return type:
- 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:
- 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:
- 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.
- fulfilled(solution)
Returns True iff a constraint is held over the whole solution
- Parameters:
solution (timor.task.Solution.SolutionBase)
- Return type:
- is_valid_at(solution, t)
Checks whether the given joint angles are within the defined limits at time t.
- Parameters:
solution (timor.task.Solution.SolutionBase)
t (float)
- Return type:
- is_valid_until(solution, t)
Checks that a constraint is valid on a subset of a solution until time t.
- Parameters:
solution (timor.task.Solution.SolutionBase)
t (float)
- Return type:
- 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]
- 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.
- 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)

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:
task (timor.task.Task.Task)
robot (timor.RobotBase)
q (numpy.ndarray)
dq (numpy.ndarray)
ddq (Optional[numpy.ndarray])
- Return type:
- 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:
- 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:
- _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:
- 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:
- 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.
- fulfilled(solution)
Returns True iff a constraint is held over the whole solution
- Parameters:
solution (timor.task.Solution.SolutionBase)
- Return type:
- is_valid_at(solution, t)
Evaluates the solution at time t
- Parameters:
solution (timor.task.Solution.SolutionBase)
t (float)
- Return type:
- is_valid_until(solution, t)
Evaluates the solution up to time t
- Parameters:
solution (timor.task.Solution.SolutionBase)
t (float)
- Return type:
- q
- robot_limit_types = ('q', 'dq', 'ddq', 'tau')
- tau
- 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.
- 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

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:
task (Optional[timor.task.Task.Task])
robot (timor.RobotBase)
q (numpy.ndarray)
dq (numpy.ndarray)
ddq (Optional[numpy.ndarray])
- Return type:
- 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:
- class timor.task.Constraints.SelfCollisionFree(safety_margin=0)

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:
task (Optional[timor.task.Task.Task])
robot (timor.RobotBase)
q (numpy.ndarray)
dq (numpy.ndarray)
ddq (Optional[numpy.ndarray])
- Return type:
- 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:
- 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:
- 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:
- 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:
- 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.
- fulfilled(solution)
Returns True iff a constraint is held over the whole solution
- Parameters:
solution (timor.task.Solution.SolutionBase)
- Return type:
- is_valid_at(solution, t)
Checks whether the robot is in collision with the environment or itself at time t.
- Parameters:
solution (timor.task.Solution.SolutionBase)
t (float)
- Return type:
- is_valid_until(solution, t)
Checks that a constraint is valid on a subset of a solution until time t.
- Parameters:
solution (timor.task.Solution.SolutionBase)
t (float)
- Return type:
- 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.
- 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