RepeatUnlessFailureEachTick Class
Decorator that ticks its child up to num_cycles times, advancing one iteration per parent tick. More...
Declaration
Included Headers
Base class
| class | BT::DecoratorNode |
Public Constructors Index
| RepeatUnlessFailureEachTick (const std::string &name, const BT::NodeConfiguration &config) | |
Public Destructor Index
| ~RepeatUnlessFailureEachTick () override=default | |
Private Member Functions Index
| BT::NodeStatus | tick () override |
|
Tick the child once per call, advancing the iteration counter only on SUCCESS. More... | |
| void | halt () override |
|
Reset the iteration counter and halt the child. More... | |
Private Member Attributes Index
| int | cycle_count_ { 0 } |
|
Number of completed successful iterations. Reset to 0 on FAILURE, on halt, or after returning SUCCESS. More... | |
Public Static Functions Index
| static BT::PortsList | providedPorts () |
|
Required implementation of the static providedPorts function. More... | |
| static BT::KeyValueVector | metadata () |
Description
Decorator that ticks its child up to num_cycles times, advancing one iteration per parent tick.
A safe replacement for the stock BehaviorTree.CPP Repeat and KeepRunningUntilFailure decorators that respects the BT tick paradigm:
- At most one child iteration runs per parent tick. When the child returns SUCCESS, this decorator returns RUNNING so the parent re-ticks on the next pass instead of looping inside one tick.
- When the child returns FAILURE, this decorator returns FAILURE.
- When the cumulative successful iteration count reaches num_cycles, this decorator returns SUCCESS.
- When num_cycles is -1 (the default), the loop runs forever — equivalent to the legacy KeepRunningUntilFailure semantics, but without the tick-paradigm violation present in Repeat.
Because each iteration yields a tick back to the parent, an infinite loop with a synchronous always-SUCCESS child cannot deadlock the tree the way Repeat num_cycles="-1" does.
| Data Port Name | Port Type | Object Type |
|---|---|---|
| num_cycles | input | int |
Definition at line 33 of file repeat_unless_failure_each_tick.hpp.
Public Constructors
RepeatUnlessFailureEachTick()
|
Declaration at line 36 of file repeat_unless_failure_each_tick.hpp, definition at line 35 of file repeat_unless_failure_each_tick.cpp.
Public Destructor
~RepeatUnlessFailureEachTick()
| default |
Definition at line 38 of file repeat_unless_failure_each_tick.hpp.
Private Member Functions
halt()
|
Reset the iteration counter and halt the child.
Declaration at line 58 of file repeat_unless_failure_each_tick.hpp, definition at line 113 of file repeat_unless_failure_each_tick.cpp.
tick()
|
Tick the child once per call, advancing the iteration counter only on SUCCESS.
- Returns
SUCCESS once num_cycles successful child iterations have been completed (or never, if num_cycles == -1). Returns FAILURE if the child fails. Returns RUNNING otherwise.
- Exceptions
-
BT::LogicError if the child returns IDLE.
Declaration at line 55 of file repeat_unless_failure_each_tick.hpp, definition at line 54 of file repeat_unless_failure_each_tick.cpp.
Private Member Attributes
cycle_count_
|
Number of completed successful iterations. Reset to 0 on FAILURE, on halt, or after returning SUCCESS.
Definition at line 61 of file repeat_unless_failure_each_tick.hpp.
Public Static Functions
metadata()
| static |
Declaration at line 46 of file repeat_unless_failure_each_tick.hpp, definition at line 48 of file repeat_unless_failure_each_tick.cpp.
providedPorts()
| static |
Required implementation of the static providedPorts function.
- Returns
The list of input and output ports used by this behavior.
Declaration at line 44 of file repeat_unless_failure_each_tick.hpp, definition at line 40 of file repeat_unless_failure_each_tick.cpp.
The documentation for this class was generated from the following files:
Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.9.8.