Skip to main content

RepeatUnlessFailureEachTick Class

Decorator that ticks its child up to num_cycles times, advancing one iteration per parent tick. More...

Declaration

class moveit_pro::behaviors::RepeatUnlessFailureEachTick { ... }

Included Headers

#include <repeat_unless_failure_each_tick.hpp>

Base class

classBT::DecoratorNode

Public Constructors Index

RepeatUnlessFailureEachTick (const std::string &name, const BT::NodeConfiguration &config)

Public Destructor Index

~RepeatUnlessFailureEachTick () override=default

Private Member Functions Index

BT::NodeStatustick () override

Tick the child once per call, advancing the iteration counter only on SUCCESS. More...

voidhalt () override

Reset the iteration counter and halt the child. More...

Private Member Attributes Index

intcycle_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::PortsListprovidedPorts ()

Required implementation of the static providedPorts function. More...

static BT::KeyValueVectormetadata ()

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 NamePort TypeObject Type
num_cyclesinputint

Definition at line 33 of file repeat_unless_failure_each_tick.hpp.

Public Constructors

RepeatUnlessFailureEachTick()

moveit_pro::behaviors::RepeatUnlessFailureEachTick::RepeatUnlessFailureEachTick (const std::string & name, const BT::NodeConfiguration & config)

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()

moveit_pro::behaviors::RepeatUnlessFailureEachTick::~RepeatUnlessFailureEachTick ()
default

Definition at line 38 of file repeat_unless_failure_each_tick.hpp.

Private Member Functions

halt()

void moveit_pro::behaviors::RepeatUnlessFailureEachTick::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()

BT::NodeStatus moveit_pro::behaviors::RepeatUnlessFailureEachTick::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_

int moveit_pro::behaviors::RepeatUnlessFailureEachTick::cycle_count_ { 0 }

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()

BT::KeyValueVector moveit_pro::behaviors::RepeatUnlessFailureEachTick::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()

BT::PortsList moveit_pro::behaviors::RepeatUnlessFailureEachTick::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.