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
size_t failureThreshold() const
const NodeConfiguration & config() const
Definition: tree_node.cpp:127
static constexpr const char * THRESHOLD_SUCCESS
Definition: parallel_node.h:72
ParallelNode(const std::string &name, int success_threshold, int failure_threshold=1)
static constexpr const char * THRESHOLD_FAILURE
Definition: parallel_node.h:73
~ParallelNode() override=default
const std::string & name() const
Name of the instance, not the type.
Definition: tree_node.cpp:101
std::set< int > skip_list_
Definition: parallel_node.h:69
bool read_parameter_from_ports_
Definition: parallel_node.h:71
void setSuccessThreshold(int threshold_M)
virtual void halt() override
std::unordered_map< std::string, PortInfo > PortsList
Definition: basic_types.h:333
void setFailureThreshold(int threshold_M)
size_t successThreshold() const
virtual BT::NodeStatus tick() override
Method to be implemented by the user.
The ParallelNode execute all its children concurrently, but not in separate threads! ...
Definition: parallel_node.h:40
NodeStatus
Definition: basic_types.h:35
static PortsList providedPorts()
Definition: parallel_node.h:47


behaviortree_cpp_v3
Author(s): Michele Colledanchise, Davide Faconti
autogenerated on Mon Jul 3 2023 02:50:14