File tree 4 files changed +15
-11
lines changed
include/behaviortree_cpp/decorators
4 files changed +15
-11
lines changed Original file line number Diff line number Diff line change @@ -37,20 +37,22 @@ class RepeatNode : public DecoratorNode
37
37
{
38
38
public:
39
39
40
- RepeatNode (const std::string& name, unsigned int NTries);
40
+ RepeatNode (const std::string& name, int NTries);
41
41
42
42
RepeatNode (const std::string& name, const NodeConfiguration& config);
43
43
44
44
virtual ~RepeatNode () override = default ;
45
45
46
46
static PortsList providedPorts ()
47
47
{
48
- return { InputPort<unsigned >(NUM_CYCLES, " Repeat a succesful child up to N times" ) };
48
+ return { InputPort<int >(NUM_CYCLES,
49
+ " Repeat a succesful child up to N times. "
50
+ " Use -1 to create an infinite loop." ) };
49
51
}
50
52
51
53
private:
52
- unsigned num_cycles_;
53
- unsigned try_index_;
54
+ int num_cycles_;
55
+ int try_index_;
54
56
55
57
bool read_parameter_from_ports_;
56
58
static constexpr const char * NUM_CYCLES = " num_cycles" ;
Original file line number Diff line number Diff line change @@ -37,22 +37,24 @@ class RetryNode : public DecoratorNode
37
37
{
38
38
public:
39
39
40
- RetryNode (const std::string& name, unsigned int NTries);
40
+ RetryNode (const std::string& name, int NTries);
41
41
42
42
RetryNode (const std::string& name, const NodeConfiguration& config);
43
43
44
44
virtual ~RetryNode () override = default ;
45
45
46
46
static PortsList providedPorts ()
47
47
{
48
- return { InputPort<unsigned >(NUM_ATTEMPTS, " Execute again a failing child up to N times" ) };
48
+ return { InputPort<int >(NUM_ATTEMPTS,
49
+ " Execute again a failing child up to N times. "
50
+ " Use -1 to create an infinite loop." ) };
49
51
}
50
52
51
53
virtual void halt () override ;
52
54
53
55
private:
54
- unsigned int max_attempts_;
55
- unsigned int try_index_;
56
+ int max_attempts_;
57
+ int try_index_;
56
58
57
59
bool read_parameter_from_ports_;
58
60
static constexpr const char * NUM_ATTEMPTS = " num_attempts" ;
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ namespace BT
17
17
{
18
18
constexpr const char * RepeatNode::NUM_CYCLES;
19
19
20
- RepeatNode::RepeatNode (const std::string& name, unsigned int NTries)
20
+ RepeatNode::RepeatNode (const std::string& name, int NTries)
21
21
: DecoratorNode(name, {} ),
22
22
num_cycles_ (NTries),
23
23
try_index_ (0 ),
@@ -47,7 +47,7 @@ NodeStatus RepeatNode::tick()
47
47
48
48
setStatus (NodeStatus::RUNNING);
49
49
50
- while (try_index_ < num_cycles_)
50
+ while (try_index_ < num_cycles_ || num_cycles_== - 1 )
51
51
{
52
52
NodeStatus child_state = child_node_->executeTick ();
53
53
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ namespace BT
17
17
{
18
18
constexpr const char * RetryNode::NUM_ATTEMPTS;
19
19
20
- RetryNode::RetryNode (const std::string& name, unsigned int NTries)
20
+ RetryNode::RetryNode (const std::string& name, int NTries)
21
21
: DecoratorNode(name, {} ),
22
22
max_attempts_ (NTries),
23
23
try_index_ (0 ),
You can’t perform that action at this time.
0 commit comments