pycram.task

Implementation of TaskTrees using anytree.

Module Contents

Classes

NoOperation

TaskTreeNode

TaskTreeNode represents one function that was called during a pycram plan.

SimulatedTaskTree

TaskTree for execution in a 'new' simulation.

Functions

reset_tree(→ None)

Reset the current task tree to an empty root (NoOperation) node.

with_tree(→ typing_extensions.Callable)

Decorator that records the function name, arguments and execution metadata in the task tree.

Attributes

task_tree

Current TaskTreeNode

class pycram.task.NoOperation
perform()
__repr__()

Return repr(self).

class pycram.task.TaskTreeNode(action: typing_extensions.Optional[pycram.designators.actions.Action] = NoOperation(), parent: typing_extensions.Optional[TaskTreeNode] = None, children: typing_extensions.Optional[typing_extensions.List[TaskTreeNode]] = None, reason: typing_extensions.Optional[Exception] = None)

Bases: anytree.NodeMixin

TaskTreeNode represents one function that was called during a pycram plan. Additionally, meta information is stored.

Create a TaskTreeNode

Parameters:
  • action – The action and that is performed, defaults to None

  • parent – The parent function of this function. None if this the parent, optional

  • children – An iterable of TaskTreeNode with the ordered children, optional

property name
action: typing_extensions.Optional[pycram.designators.actions.Action]

The action and that is performed or None if nothing was performed

status: pycram.datastructures.enums.TaskStatus

The status of the node from the TaskStatus enum.

start_time: typing_extensions.Optional[datetime.datetime]

The starting time of the function, optional

end_time: typing_extensions.Optional[datetime.datetime]

The ending time of the function, optional

__str__()
__repr__()
__len__()

Get the number of nodes that are in this subtree.

to_sql() pycram.orm.task.TaskTreeNode

Convert this object to the corresponding object in the pycram.orm package.

Returns:

corresponding pycram.orm.task.TaskTreeNode object

insert(session: sqlalchemy.orm.session.Session, recursive: bool = True, parent: typing_extensions.Optional[TaskTreeNode] = None, use_progress_bar: bool = True, progress_bar: typing_extensions.Optional[tqdm.tqdm] = None) pycram.orm.task.TaskTreeNode

Insert this node into the database.

Parameters:
  • session – The current session with the database.

  • recursive – Rather if the entire tree should be inserted or just this node, defaults to True

  • parent – The parent node, defaults to None

  • use_progress_bar – Rather to use a progressbar or not

  • progress_bar – The progressbar to update. If a progress bar is desired and this is None, a new one will be created.

Returns:

The ORM object that got inserted

class pycram.task.SimulatedTaskTree

TaskTree for execution in a ‘new’ simulation.

__enter__()

At the beginning of a with statement the current task tree and world will be suspended and remembered. Fresh structures are then available inside the with statement.

__exit__(exc_type, exc_val, exc_tb)

Restore the old state at the end of a with block.

pycram.task.task_tree: typing_extensions.Optional[TaskTreeNode]

Current TaskTreeNode

pycram.task.reset_tree() None

Reset the current task tree to an empty root (NoOperation) node.

pycram.task.with_tree(fun: typing_extensions.Callable) typing_extensions.Callable

Decorator that records the function name, arguments and execution metadata in the task tree.

Parameters:

fun – The function to record the data from.