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='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.

Variables:

fix_parent_relationships_after_plan – Whether to fix parent relationships after planning

logger = None
fix_parent_relationships_after_plan = True
initialise()

Initialize and validate tree structure.

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

plan_new_job() py_trees.composites.Sequence | None

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.

Return type:

Optional[py_trees.Sequence]

update()

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

Return type:

py_trees.common.Status

class robokudo.tree_components.task_scheduler.IterativeTaskScheduler(name='IterativeTaskScheduler', tree_list=[])

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.

Variables:
  • tree_list – List of subtrees to cycle through

  • idx – Current index in tree_list

tree_list = []
idx = 0
setup(timeout)

Set up all trees in the list.

TODO Since we might have the same node in multiple trees, we might call setup multiple times

=> Find a way to get around this

Note

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

Parameters:

timeout (float) – Maximum time allowed for setup

Returns:

True if setup successful

Return type:

bool

plan_new_job() py_trees.composites.Sequence | None

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

Returns:

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

Return type:

Optional[py_trees.Sequence]