timor.task.Goals
Classes
A goal that is achieved when the robot is at a certain position for at least one time step t. |
|
This goal is achieved if the robot follows a prescribed end-effector trajectory. |
|
The base implementation for a task goal. |
|
Any goal that needs to test more than a single time-step to be achieved. |
|
This goal is achieved if the robot does not move for a preconfigured duration. |
|
A goal that is achieved when the robot is at a certain position for at least one time step at zero velocity |
|
This goal is achieved when the robot returns to the state it was in at a previous goal |
Module Contents
- class timor.task.Goals.At(ID, goalPose, constraints=None)

A goal that is achieved when the robot is at a certain position for at least one time step t.
The robot does not need to be still standing, though.
Pass a desired pose
- Parameters:
ID (str) – The id of the goal. This is used to identify the goal in the solution.
goalPose (timor.utilities.tolerated_pose.ToleratedPose) – The goal pose to be reached.
constraints (Sequence[timor.task.Constraints.ConstraintBase]) – A list of constraints that need to be satisfied for the goal to be achieved.
- __eq__(other)
At goals are same if they have the same constraints and desired pose
- __getstate__()
Return objects which will be pickled and saved.
- __hash__()
Hashes the goal by its id
- __setstate__(state)
Take object from parameter and use it to retrieve class state.
- __slots__ = ()
- _achieved(solution, t_goal, idx_goal)
Returns true, if the solution satisfies this goal.
- Parameters:
solution (timor.task.Solution.SolutionBase) – Any solution instance that must contain a time at which this goal was solved
t_goal (float)
idx_goal (int)
- Returns:
True if the end effector placement at time t is within the defined tolerances for the desired pose
- Return type:
- _assert_constraints_local()
Checks that the constraints of this goal have a “local meaning”.
- Raises:
ValueError if one of the constraints would be better off as a global constraint.
- 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:
- _get_t_idx_goal(solution)
Finds the time t and the index within the time array idx at which the goal is achieved.
- Parameters:
solution (timor.task.Solution.SolutionBase)
- Return type:
- _id = ''
- _valid(solution, t_goal, idx_goal)
Checks all goal-level constraints
- Parameters:
solution (timor.task.Solution.SolutionBase)
t_goal (float)
idx_goal (int)
- Return type:
- achieved(solution)
Calls the custom _achieved method and checks that constraints are held
- Parameters:
solution (timor.task.Solution.SolutionBase)
- Return type:
- constraints = None
- classmethod from_json_data(d, *args, **kwargs)
Loads the At goal to a dictionary description.
- Parameters:
d (Dict[str, any])
- classmethod from_json_file(filepath, *args, **kwargs)
Factory method to load a class instance from a json file.
- Parameters:
filepath (Union[pathlib.Path, str]) – The path to the json file.
args – Additional arguments to pass to the from_json_data factory method of the specific class.
kwargs – Additional arguments to pass to the from_json_data factory method of the specific class.
- static goal_from_json_data(description, frames)
Maps a json description to a goal instance
- Parameters:
description (Dict[str, any])
frames (timor.utilities.frames.FrameTree)
- Return type:
- green_material
- property nominal_goal
The nominal goal pose
- 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.
- class timor.task.Goals.Follow(ID, trajectory, external_forces=None, external_torques=None, force_torque_reference_frame='world', constraints=None)

This goal is achieved if the robot follows a prescribed end-effector trajectory.
Follow a given trajectory.
- Parameters:
ID (str) – The goal ID
trajectory (timor.utilities.trajectory.Trajectory) – The trajectory to follow (a sequence of desired poses)
external_forces (Optional[Collection[float]]) – An external force to be applied to the robot during execution of the goal
external_torques (Optional[Collection[float]]) – An external torque to be applied to the robot during execution of the goal
force_torque_reference_frame (str) – The reference frame in which forces/torques are expressed
constraints (Sequence[timor.task.Constraints.ConstraintBase]) – Goal-level constraints
- __eq__(other)
Two follow goals are equal if they have the same duration, trajectory and constraints.
- __getstate__()
Return objects which will be pickled and saved.
- __hash__()
Hashes the goal by its id
- __setstate__(state)
Take object from parameter and use it to retrieve class state.
- __slots__ = ()
- _achieved(solution, t_goal, idx_goal)
Implements check if goal achieved at claimed time
- Note:
Side-effect if desired trajectory is not timed: Will set self.duration such that the trajectory is followed in the time-interval [t_goal-duration, t_goal]. This allows constraint checking in _valid to know all time-steps within this goal.
- Parameters:
- Return type:
- _assert_constraints_local()
Checks that the constraints of this goal have a “local meaning”.
- Raises:
ValueError if one of the constraints would be better off as a global constraint.
- 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:
- _duration
- _external_forces: numpy.ndarray = None
- _external_torques: numpy.ndarray = None
- _get_t_idx_goal(solution)
Finds the time t and the index within the time array idx at which the goal is achieved.
- Parameters:
solution (timor.task.Solution.SolutionBase)
- Return type:
- _id = ''
- _trajectory: timor.utilities.trajectory.Trajectory
- _valid(solution, t_goal, idx_goal)
A goal with duration needs to ensure that its constraints hold at all time-steps within this duration.
- Parameters:
solution (timor.task.Solution.SolutionBase)
t_goal (float)
idx_goal (int)
- Return type:
- achieved(solution)
Calls the custom _achieved method and checks that constraints are held
- Parameters:
solution (timor.task.Solution.SolutionBase)
- Return type:
- constraints = None
- classmethod from_json_data(d, *args, **kwargs)
Loads the Follow goal from a dictionary description.
- Parameters:
d (Dict[str, any])
- 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.
- get_time_range_goal(solution)
Get all time-steps in solution that belong to this goal’s duration as list of times and indices.
- Parameters:
solution (timor.task.Solution.SolutionBase) – Solution to evaluate this goal with duration on.
- Returns:
A tuple of times that are included in the duration of the goal
A range of indices into the solution’s time array that fall into the duration of this goal
- Return type:
Tuple[numpy.ndarray, range]
- static goal_from_json_data(description, frames)
Maps a json description to a goal instance
- Parameters:
description (Dict[str, any])
frames (timor.utilities.frames.FrameTree)
- Return type:
- green_material
- 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 trajectory: timor.utilities.trajectory.Trajectory
The trajectory to follow along
- Return type:
- visualize(viz, *, scale=0.33, num_markers=2, show_name=False)
Shows the follow goal with num_markers triads to show desired orientation.
- property wrench: numpy.ndarray
The external wrench applied to the end effector
- Return type:
- class timor.task.Goals.GoalBase(ID, constraints=None)

The base implementation for a task goal.
Initiate goals with the according parameters
- Parameters:
ID (str) – The id of the goal. This is used to identify the goal in the solution.
constraints (Sequence[timor.task.Constraints.ConstraintBase]) – A list of constraints that need to be satisfied for the goal to be achieved - but only here. (Which separates them from task goals which must hold for a whole task)
- abstractmethod __eq__(other)
Enforce the implementation
- __getstate__()
Return objects which will be pickled and saved.
- __hash__()
Hashes the goal by its id
- __setstate__(state)
Take object from parameter and use it to retrieve class state.
- __slots__ = ()
- abstractmethod _achieved(solution, t_goal, idx_goal)
Needs to be implemented by children according to the goal
- Parameters:
solution (timor.task.Solution.SolutionBase)
t_goal (float)
idx_goal (int)
- Return type:
- _assert_constraints_local()
Checks that the constraints of this goal have a “local meaning”.
- Raises:
ValueError if one of the constraints would be better off as a global constraint.
- 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:
- _get_t_idx_goal(solution)
Finds the time t and the index within the time array idx at which the goal is achieved.
- Parameters:
solution (timor.task.Solution.SolutionBase)
- Return type:
- _id = ''
- _valid(solution, t_goal, idx_goal)
Checks all goal-level constraints
- Parameters:
solution (timor.task.Solution.SolutionBase)
t_goal (float)
idx_goal (int)
- Return type:
- achieved(solution)
Calls the custom _achieved method and checks that constraints are held
- Parameters:
solution (timor.task.Solution.SolutionBase)
- Return type:
- constraints = None
- classmethod from_json_data(d, *args, **kwargs)
- Abstractmethod:
- Parameters:
d (Dict[str, any])
Deserializes a goal from a dictionary
- classmethod from_json_file(filepath, *args, **kwargs)
Factory method to load a class instance from a json file.
- Parameters:
filepath (Union[pathlib.Path, str]) – The path to the json file.
args – Additional arguments to pass to the from_json_data factory method of the specific class.
kwargs – Additional arguments to pass to the from_json_data factory method of the specific class.
- static goal_from_json_data(description, frames)
Maps a json description to a goal instance
- Parameters:
description (Dict[str, any])
frames (timor.utilities.frames.FrameTree)
- Return type:
- green_material
- abstractmethod to_json_data()
Returns a json-compatible dictionary representation of the goal.
- 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.
- abstractmethod visualize(viz, scale=0.33, show_name=False)
Every goal should have a visualization. The default color is green.
- 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) – Whether to show the name of the goal in the visualization.
- Return type:
None
- class timor.task.Goals.GoalWithDuration(ID, duration, constraints=None)

Any goal that needs to test more than a single time-step to be achieved.
This also includes checking the goal constraints at any point of the goal’s duration.
Construct a goal with duration.
- Parameters:
ID (str)
duration (float)
constraints (Sequence[timor.task.Constraints.ConstraintBase])
- abstractmethod __eq__(other)
Enforce the implementation
- __getstate__()
Return objects which will be pickled and saved.
- __hash__()
Hashes the goal by its id
- __setstate__(state)
Take object from parameter and use it to retrieve class state.
- __slots__ = ()
- abstractmethod _achieved(solution, t_goal, idx_goal)
Needs to be implemented by children according to the goal
- Parameters:
solution (timor.task.Solution.SolutionBase)
t_goal (float)
idx_goal (int)
- Return type:
- _assert_constraints_local()
Checks that the constraints of this goal have a “local meaning”.
- Raises:
ValueError if one of the constraints would be better off as a global constraint.
- 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:
- _duration
- _get_t_idx_goal(solution)
Finds the time t and the index within the time array idx at which the goal is achieved.
- Parameters:
solution (timor.task.Solution.SolutionBase)
- Return type:
- _id = ''
- _valid(solution, t_goal, idx_goal)
A goal with duration needs to ensure that its constraints hold at all time-steps within this duration.
- Parameters:
solution (timor.task.Solution.SolutionBase)
t_goal (float)
idx_goal (int)
- Return type:
- achieved(solution)
Calls the custom _achieved method and checks that constraints are held
- Parameters:
solution (timor.task.Solution.SolutionBase)
- Return type:
- constraints = None
- classmethod from_json_data(d, *args, **kwargs)
- Abstractmethod:
- Parameters:
d (Dict[str, any])
Deserializes a goal from a dictionary
- 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.
- get_time_range_goal(solution)
Get all time-steps in solution that belong to this goal’s duration as list of times and indices.
- Parameters:
solution (timor.task.Solution.SolutionBase) – Solution to evaluate this goal with duration on.
- Returns:
A tuple of times that are included in the duration of the goal
A range of indices into the solution’s time array that fall into the duration of this goal
- Return type:
Tuple[numpy.ndarray, range]
- static goal_from_json_data(description, frames)
Maps a json description to a goal instance
- Parameters:
description (Dict[str, any])
frames (timor.utilities.frames.FrameTree)
- Return type:
- green_material
- abstractmethod to_json_data()
Returns a json-compatible dictionary representation of the goal.
- 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.
- abstractmethod visualize(viz, scale=0.33, show_name=False)
Every goal should have a visualization. The default color is green.
- 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) – Whether to show the name of the goal in the visualization.
- Return type:
None
- class timor.task.Goals.Pause(ID, duration, constraints=None)

This goal is achieved if the robot does not move for a preconfigured duration.
Construct a goal with duration.
- Parameters:
ID (str)
duration (float)
constraints (Sequence[timor.task.Constraints.ConstraintBase])
- __eq__(other)
Two pause goals are equal if there’s (almost) the same pause and constraints.
- __getstate__()
Return objects which will be pickled and saved.
- __hash__()
Hashes the goal by its id
- __setstate__(state)
Take object from parameter and use it to retrieve class state.
- __slots__ = ()
- _achieved(solution, t_goal, idx_goal)
Returns true, if the robot does not move for a preconfigured duration, starting at t_goal.
- Parameters:
solution (timor.task.Solution.SolutionBase)
t_goal (float)
idx_goal (int)
- Return type:
- _assert_constraints_local()
Checks that the constraints of this goal have a “local meaning”.
- Raises:
ValueError if one of the constraints would be better off as a global constraint.
- 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:
- _duration
- _get_t_idx_goal(solution)
Finds the time t and the index within the time array idx at which the goal is achieved.
- Parameters:
solution (timor.task.Solution.SolutionBase)
- Return type:
- _id = ''
- _valid(solution, t_goal, idx_goal)
A goal with duration needs to ensure that its constraints hold at all time-steps within this duration.
- Parameters:
solution (timor.task.Solution.SolutionBase)
t_goal (float)
idx_goal (int)
- Return type:
- achieved(solution)
Calls the custom _achieved method and checks that constraints are held
- Parameters:
solution (timor.task.Solution.SolutionBase)
- Return type:
- constraints = None
- classmethod from_json_data(d, *args, **kwargs)
Loads the Pause goal from a dictionary description.
- Parameters:
d (Dict[str, any])
- 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.
- get_time_range_goal(solution)
Get all time-steps in solution that belong to this goal’s duration as list of times and indices.
- Parameters:
solution (timor.task.Solution.SolutionBase) – Solution to evaluate this goal with duration on.
- Returns:
A tuple of times that are included in the duration of the goal
A range of indices into the solution’s time array that fall into the duration of this goal
- Return type:
Tuple[numpy.ndarray, range]
- static goal_from_json_data(description, frames)
Maps a json description to a goal instance
- Parameters:
description (Dict[str, any])
frames (timor.utilities.frames.FrameTree)
- Return type:
- green_material
- 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.
- class timor.task.Goals.Reach(ID, goalPose, velocity_tolerance=Tolerance.Abs6dPoseTolerance.default(), constraints=None)

A goal that is achieved when the robot is at a certain position for at least one time step at zero velocity
Reach a desired pose while standing still.
- Parameters:
ID (str) – The id of the goal. This is used to identify the goal in the solution.
goalPose (timor.utilities.tolerated_pose.ToleratedPose) – The goal pose to be reached.
velocity_tolerance (timor.task.Tolerance.ToleranceBase) – Defines the velocity tolerance for v_desired.
constraints (Sequence[timor.task.Constraints.ConstraintBase]) – A list of constraints that need to be satisfied for the goal to be achieved.
- __eq__(other)
Reach goals are same if they have the same constraints, velocity, and desired pose
- __getstate__()
Return objects which will be pickled and saved.
- __hash__()
Hashes the goal by its id
- __setstate__(state)
Take object from parameter and use it to retrieve class state.
- __slots__ = ()
- _achieved(solution, t_goal, idx_goal)
Returns true, if position and velocity are within the defined tolerances
- Parameters:
solution (timor.task.Solution.SolutionBase)
t_goal (float)
idx_goal (int)
- Return type:
- _assert_constraints_local()
Checks that the constraints of this goal have a “local meaning”.
- Raises:
ValueError if one of the constraints would be better off as a global constraint.
- 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:
- _get_t_idx_goal(solution)
Finds the time t and the index within the time array idx at which the goal is achieved.
- Parameters:
solution (timor.task.Solution.SolutionBase)
- Return type:
- _id = ''
- _valid(solution, t_goal, idx_goal)
Checks all goal-level constraints
- Parameters:
solution (timor.task.Solution.SolutionBase)
t_goal (float)
idx_goal (int)
- Return type:
- achieved(solution)
Calls the custom _achieved method and checks that constraints are held
- Parameters:
solution (timor.task.Solution.SolutionBase)
- Return type:
- constraints = None
- classmethod from_json_data(d, *args, **kwargs)
Loads the Reach goal to a dictionary description.
- Parameters:
d (Dict[str, any])
- classmethod from_json_file(filepath, *args, **kwargs)
Factory method to load a class instance from a json file.
- Parameters:
filepath (Union[pathlib.Path, str]) – The path to the json file.
args – Additional arguments to pass to the from_json_data factory method of the specific class.
kwargs – Additional arguments to pass to the from_json_data factory method of the specific class.
- static goal_from_json_data(description, frames)
Maps a json description to a goal instance
- Parameters:
description (Dict[str, any])
frames (timor.utilities.frames.FrameTree)
- Return type:
- green_material
- property nominal_goal
The nominal goal pose
- 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_tolerance
- class timor.task.Goals.ReturnTo(ID, returnToGoal=None, epsilon=0.0001, constraints=None)

This goal is achieved when the robot returns to the state it was in at a previous goal
Return to a previous goal
- Parameters:
ID (str) – The id of the goal. This is used to identify the goal in the solution.
returnToGoal (Optional[str]) – ID of other goal which should be matched again; can be left out to denote the start of the solution trajectory.
epsilon (float) – Allowed L2 distance between joint states at this goal and the the other goal.
constraints (Sequence[timor.task.Constraints.ConstraintBase])
- __eq__(other)
Return goals are same if they have the same constraints, tolerance, and return to option
- __getstate__()
Return objects which will be pickled and saved.
- __hash__()
Hashes the goal by its id
- __setstate__(state)
Take object from parameter and use it to retrieve class state.
- __slots__ = ()
- _achieved(solution, t_goal, idx_goal)
Returns true, if position, velocity and acceleration are (almost) equal to those at t=return_to_t
- Parameters:
solution (timor.task.Solution.SolutionBase)
t_goal (float)
idx_goal (int)
- Return type:
- _assert_constraints_local()
Checks that the constraints of this goal have a “local meaning”.
- Raises:
ValueError if one of the constraints would be better off as a global constraint.
- 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:
- _get_t_idx_goal(solution)
Finds the time t and the index within the time array idx at which the goal is achieved.
- Parameters:
solution (timor.task.Solution.SolutionBase)
- Return type:
- _id = ''
- _valid(solution, t_goal, idx_goal)
Checks all goal-level constraints
- Parameters:
solution (timor.task.Solution.SolutionBase)
t_goal (float)
idx_goal (int)
- Return type:
- achieved(solution)
Calls the custom _achieved method and checks that constraints are held
- Parameters:
solution (timor.task.Solution.SolutionBase)
- Return type:
- constraints = None
- desired_pose: timor.utilities.tolerated_pose.ToleratedPose | None = None
- distance_tolerance
- classmethod from_json_data(d, *args, **kwargs)
Loads the Return goal to a dictionary description.
- Parameters:
d (Dict[str, any])
- classmethod from_json_file(filepath, *args, **kwargs)
Factory method to load a class instance from a json file.
- Parameters:
filepath (Union[pathlib.Path, str]) – The path to the json file.
args – Additional arguments to pass to the from_json_data factory method of the specific class.
kwargs – Additional arguments to pass to the from_json_data factory method of the specific class.
- static goal_from_json_data(description, frames)
Maps a json description to a goal instance
- Parameters:
description (Dict[str, any])
frames (timor.utilities.frames.FrameTree)
- Return type:
- green_material
- return_to_goal = 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.