repeat_node.h
Go to the documentation of this file.
1 /* Copyright (C) 2015-2018 Michele Colledanchise - All Rights Reserved
2  * Copyright (C) 2018-2022 Davide Faconti, Eurecat - All Rights Reserved
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
5 * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
6 * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
7 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
10 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
11 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12 */
13 
14 #pragma once
15 
17 
18 namespace BT
19 {
35 class RepeatNode : public DecoratorNode
36 {
37 public:
38  RepeatNode(const std::string& name, int NTries);
39 
40  RepeatNode(const std::string& name, const NodeConfig& config);
41 
42  virtual ~RepeatNode() override = default;
43 
45  {
46  return { InputPort<int>(NUM_CYCLES, "Repeat a successful child up to N times. "
47  "Use -1 to create an infinite loop.") };
48  }
49 
50 private:
53  bool all_skipped_ = true;
54 
56  static constexpr const char* NUM_CYCLES = "num_cycles";
57 
58  virtual NodeStatus tick() override;
59 
60  void halt() override;
61 };
62 
63 } // namespace BT
BT
Definition: ex01_wrap_legacy.cpp:29
BT::TreeNode::config
const NodeConfig & config() const
Definition: tree_node.cpp:345
BT::RepeatNode::providedPorts
static PortsList providedPorts()
Definition: repeat_node.h:44
BT::DecoratorNode
Definition: decorator_node.h:8
BT::RepeatNode::repeat_count_
int repeat_count_
Definition: repeat_node.h:52
BT::PortsList
std::unordered_map< std::string, PortInfo > PortsList
Definition: basic_types.h:585
BT::RepeatNode::tick
virtual NodeStatus tick() override
Method to be implemented by the user.
Definition: repeat_node.cpp:35
BT::RepeatNode::~RepeatNode
virtual ~RepeatNode() override=default
BT::RepeatNode::NUM_CYCLES
static constexpr const char * NUM_CYCLES
Definition: repeat_node.h:56
BT::TreeNode::name
const std::string & name() const
Name of the instance, not the type.
Definition: tree_node.cpp:296
BT::RepeatNode::RepeatNode
RepeatNode(const std::string &name, int NTries)
Definition: repeat_node.cpp:19
BT::RepeatNode::read_parameter_from_ports_
bool read_parameter_from_ports_
Definition: repeat_node.h:55
BT::RepeatNode::all_skipped_
bool all_skipped_
Definition: repeat_node.h:53
BT::RepeatNode::num_cycles_
int num_cycles_
Definition: repeat_node.h:51
BT::NodeConfig
Definition: tree_node.h:73
BT::RepeatNode::halt
void halt() override
The method used to interrupt the execution of this node.
Definition: repeat_node.cpp:105
decorator_node.h
BT::RepeatNode
The RepeatNode is used to execute a child several times, as long as it succeed.
Definition: repeat_node.h:35
BT::NodeStatus
NodeStatus
Definition: basic_types.h:33


behaviortree_cpp_v4
Author(s): Davide Faconti
autogenerated on Fri Jun 28 2024 02:20:08