parallel_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 
16 #include <set>
18 
19 namespace BT
20 {
40 class ParallelNode : public ControlNode
41 {
42 public:
43  ParallelNode(const std::string& name, int success_threshold, int failure_threshold = 1);
44 
45  ParallelNode(const std::string& name, const NodeConfiguration& config);
46 
48  {
49  return {InputPort<int>(THRESHOLD_SUCCESS, "number of childen which need to succeed "
50  "to "
51  "trigger a SUCCESS"),
52  InputPort<int>(THRESHOLD_FAILURE, 1,
53  "number of childen which need to fail to trigger a FAILURE")};
54  }
55 
56  ~ParallelNode() override = default;
57 
58  virtual void halt() override;
59 
60  size_t successThreshold() const;
61  size_t failureThreshold() const;
62  void setSuccessThreshold(int threshold_M);
63  void setFailureThreshold(int threshold_M);
64 
65 private:
68 
69  std::set<int> skip_list_;
70 
72  static constexpr const char* THRESHOLD_SUCCESS = "success_threshold";
73  static constexpr const char* THRESHOLD_FAILURE = "failure_threshold";
74 
75  virtual BT::NodeStatus tick() override;
76 };
77 
78 } // namespace BT
BT::ParallelNode::tick
virtual BT::NodeStatus tick() override
Method to be implemented by the user.
Definition: parallel_node.cpp:41
BT
Definition: ex01_wrap_legacy.cpp:29
BT::ParallelNode::THRESHOLD_FAILURE
static constexpr const char * THRESHOLD_FAILURE
Definition: parallel_node.h:73
BT::ParallelNode
The ParallelNode execute all its children concurrently, but not in separate threads!
Definition: parallel_node.h:40
BT::ParallelNode::success_threshold_
int success_threshold_
Definition: parallel_node.h:66
BT::PortsList
std::unordered_map< std::string, PortInfo > PortsList
Definition: basic_types.h:342
BT::TreeNode::config
const NodeConfiguration & config() const
Definition: tree_node.cpp:127
BT::NodeConfiguration
Definition: tree_node.h:44
BT::ParallelNode::read_parameter_from_ports_
bool read_parameter_from_ports_
Definition: parallel_node.h:71
BT::ParallelNode::failureThreshold
size_t failureThreshold() const
Definition: parallel_node.cpp:152
BT::ParallelNode::setSuccessThreshold
void setSuccessThreshold(int threshold_M)
Definition: parallel_node.cpp:159
BT::ParallelNode::ParallelNode
ParallelNode(const std::string &name, int success_threshold, int failure_threshold=1)
Definition: parallel_node.cpp:24
BT::ParallelNode::successThreshold
size_t successThreshold() const
Definition: parallel_node.cpp:145
BT::ParallelNode::~ParallelNode
~ParallelNode() override=default
BT::ParallelNode::setFailureThreshold
void setFailureThreshold(int threshold_M)
Definition: parallel_node.cpp:164
control_node.h
BT::TreeNode::name
const std::string & name() const
Name of the instance, not the type.
Definition: tree_node.cpp:101
BT::ParallelNode::THRESHOLD_SUCCESS
static constexpr const char * THRESHOLD_SUCCESS
Definition: parallel_node.h:72
BT::ParallelNode::skip_list_
std::set< int > skip_list_
Definition: parallel_node.h:69
BT::ParallelNode::halt
virtual void halt() override
Definition: parallel_node.cpp:139
BT::ParallelNode::providedPorts
static PortsList providedPorts()
Definition: parallel_node.h:47
BT::ControlNode
Definition: control_node.h:21
BT::ParallelNode::failure_threshold_
int failure_threshold_
Definition: parallel_node.h:67
BT::NodeStatus
NodeStatus
Definition: basic_types.h:35


behaviortree_cpp_v3
Author(s): Michele Colledanchise, Davide Faconti
autogenerated on Wed Jun 26 2024 02:51:19