betfsm.ConcurrentFallback

Bases: GeneratorWithList

Implements a behaviortree-like Fallback node
  • success is any other outcome,
  • failure is CANCEL outcome

There is a method add_state to add underlying nodes to ConcurrentFallback, these are executed in order.

In contrast to Fallback this node runs concurrently. At each call, ConcurrentFallback runs through the list of underlying active states and:

  • If an underlying state returns CANCEL, it becomes inactive. If all states have become inactive, the ConcurrentFallback returns CANCEL
  • If an underlying active state returns another outcome besides TICKING and CANCEL, the Sequence returns the outcome of the first such state (a "success" ) and cancels the other running states.
  • If any of the states has returned TICKING, the sequence returns TICKING

In summary, it is similar to Fallback, but it calls all underlying states together (in order), and not one-by-one. ConcurrentFallback waits until all underlying states have finished ( a "join")

stateDiagram-v2 direction TB classDef successClass fill:darkgreen,color:white classDef tickingClass fill:yellow,color:black classDef otherClass fill:darkorange,color:white classDef abortClass fill:darkred,color:white state fork_state <<fork>> [*] --> fork_state fork_state --> state_1 fork_state --> state_2 state join_state <<fork>> state_1 --> join_state : CANCEL state_1 --> OTHER : OTHER outcome state_2 --> join_state : CANCEL state_2 --> OTHER : OTHER outcome join_state --> CANCEL state_1 --> TICKING : TICKING state_2 --> TICKING : TICKING state "TICKING <br> if any TICK transition <br> is received" as TICKING state "OTHER <br>returns first other outome" as OTHER state "CANCEL <br>if both transitions <br> are received" as CANCEL class SUCCEED successClass class OTHER otherClass class TICKING tickingClass class CANCEL abortClass

__init__(name, children=[])

Parameters:
  • name (str) –

    name of the sequence

  • children (List[TickingState], default: [] ) –

    a list of states you can use add_state(...) to add children.

co_execute(blackboard)

executes the underlying states in the fallback node, as much as possible concurrently. all outcomes except for CANCEL and TICKING indicate success. Fails with CANCEL when all underlying states have returned CANCEL.

Parameters:
  • blackboard (Blackboard) –