py_trees.timers module

Time related behaviours.

class py_trees.timers.Timer(name: str = 'Timer', duration: float = 5.0)

Bases: Behaviour

A simple, blocking timer behaviour running off python time.time().

This behaviour is RUNNING until the timer runs out, at which point it is SUCCESS. This can be used in a wide variety of situations - pause, duration, timeout depending on how it is wired into the tree (e.g. pause in a sequence, duration/timeout in a parallel).

The timer gets reset either upon entry (initialise()) if it hasn’t already been set and gets cleared when it either runs out, or the behaviour is interrupted by a higher priority or parent cancelling it.

Args:

name: name of the behaviour duration: length of time to run (in seconds)

Raises:

TypeError: if the provided duration is not a real number

Note

This succeeds the first time the behaviour is ticked after the expected finishing time.

Tip

Use the RunningIsFailure() decorator if you need FAILURE until the timer finishes.

initialise() None

Store the expected finishing time.

update() Status

Check the timer and update the behaviour result accordingly.

Returns:

RUNNING until timer expires, then SUCCESS.