betfsm.betfsm.ConcurrentSequence

Bases: GeneratorWithList

Implements a behaviortree-like Sequence node
  • success is SUCCEED outcome,
  • failure is any other outcome

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

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

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

In summary, it is similar to Sequence, but it calls all underlying states together (in order), and not one-by-one. ConcurrentSequence 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 : SUCCEED state_1 --> OTHER : OTHER outcome state_2 --> join_state : SUCCEED state_2 --> OTHER : OTHER outcome join_state --> SUCCEED 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 "SUCCEED <br>if both transitions <br> are received" as SUCCEED class SUCCEED successClass class OTHER otherClass class TICKING tickingClass class TIMEOUT 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 sequence, as much as possible concurrently. all outcomes except for SUCCEED and TICKING indicate failure. SUCCEEDs when all underlying states have returned SUCCEED.

Parameters:
  • blackboard