robokudo.tree_components.task_scheduler

Task scheduling components for behavior trees.

This module provides base classes for implementing task schedulers in behavior trees. Task schedulers are responsible for dynamically arranging and managing behavior tree nodes during execution.

The module supports:

  • Dynamic behavior arrangement

  • Task scheduling policies

  • Job sequence management

  • Tree structure validation

Classes

TaskSchedulerBase

Base class for task scheduling behaviors.

IterativeTaskScheduler

Task scheduler that cycles through a list of subtrees.

Module Contents

class robokudo.tree_components.task_scheduler.TaskSchedulerBase(name: str = 'TaskSchedulerBase')

Bases: py_trees.behaviour.Behaviour

Base class for task scheduling behaviors.

This Behaviour enables a dynamic arrangement of known Behaviours. It assumes that it is placed in a certain configuration in a behaviour tree: .. code-block:: text

JOB_SCHEDULING [SEQUENCE]

/ |

JOB_SCHEDULER JOB [SEQUENCE]

During startup this class will save the Job Sequence which contains as a (direct) children all the Annotators that might need to get scheduled.

… note:: In order to use this class, please use one of the deriving classes.

logger: logging.Logger = None

Logger for this class.

fix_parent_relationships_after_plan: bool = True

Whether to fix parent relationships after planning

initialise() None

Initialize and validate the tree structure.

Performs sanity checks to ensure the scheduler is in a correctly configured environment.

Raises:

AssertionError – If parent is not a Sequence or if the first child is not the scheduler

plan_new_job() typing_extensions.Optional[py_trees.composites.Sequence]

Get the new job that should be applied by the JobScheduler.

It is the responsibility of your method to return a valid py_trees.Sequence. This means especially that you have to make sure that your parent and children relations should be intact. This is important if you have to keep Instances of your Behaviours/Annotators which might get changed when being put into different py_trees.Behaviours.

Returns:

py_trees.Sequence if it can be computed or None if no plan could be found.

update() py_trees.common.Status

Update the scheduler state.

Called every time the behavior is ticked.

This will happen only once for the job scheduling.

Returns:

SUCCESS if job planned and added, FAILURE otherwise

class robokudo.tree_components.task_scheduler.IterativeTaskScheduler(name: str = 'IterativeTaskScheduler', tree_list: typing_extensions.Optional[typing_extensions.List[py_trees.composites.Sequence]] = None)

Bases: TaskSchedulerBase

Task scheduler that cycles through a list of subtrees.

A Task Scheduler that cycles iteratively through a list of given subtrees. Repeats from the beginning after the end of the list is reached.

tree_list: typing_extensions.List[py_trees.composites.Sequence] = []

List of subtrees to cycle through

idx: int = 0

Current index in tree_list

setup(timeout: float) bool

Set up all trees in the list.

Note

Since nodes may appear in multiple trees, setup may be called multiple times on the same node.

Parameters:

timeout – Maximum time allowed for setup

Returns:

True if setup successful

plan_new_job() typing_extensions.Optional[py_trees.composites.Sequence]

Plan the next job by selecting the next tree in sequence.

Returns:

New job sequence with next tree, or None if tree_list empty