betfsm_ros.TimedRepeat

Bases: GeneratorWithState

Repeats an underlying state for a given number of times and a given time interval.

stateDiagram-v2 direction LR 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 TimedRepeat { direction TB [*] --> my_state state "State" as my_state state "Waiting" as waiting my_state --> waiting : succeed waiting --> my_state : timeout } [*] --> TimedRepeat my_state --> SUCCEED : #succeed > maxcount my_state --> OTHER : other outcome my_state --> TICKING : ticking waiting --> TICKING : ticking waiting --> ABORT : time > timeout class SUCCEED successClass class OTHER otherClass class TICKING tickingClass class ABORT abortClass

__init__(name, maxcount, timeout, state, node=None)

TimedRepeat repeats the underlying state each timeout duration, until either the specified maxcount iterations is reached or the underlying state returns anything else besides TICKING or SUCCEED. TimedRepeat returns TICKING or finishes with SUCCEED if maxcount is reached, or another outcome if such outcome is returned by the underlying state.

Parameters:
  • name (str) –

    instance name

  • maxcount (int) –

    maximum of iterations, if maxcount==0, repeat until SUCCEED is returned.

  • timeout (Duration) –

    underlying state is triggered every timeout duration

  • state (TickingState) –

    underlying state

  • node (Node, default: None ) –

    ROS2 node, if None, BeTFSMNode.get_instance() is used

Note

if the underlying state returns later than timeout with a non-ticking outcome, an exception will be raised and abort is called.