parallel_node.h
Go to the documentation of this file.
1 /* Copyright (C) 2015-2018 Michele Colledanchise - All Rights Reserved
2  * Copyright (C) 2018-2020 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 #ifndef PARALLEL_NODE_H
15 #define PARALLEL_NODE_H
16 
17 #include <set>
19 
20 namespace BT
21 {
22 
23 class ParallelNode : public ControlNode
24 {
25  public:
26 
27  ParallelNode(const std::string& name, unsigned success_threshold,
28  unsigned failure_threshold = 1);
29 
30  ParallelNode(const std::string& name, const NodeConfiguration& config);
31 
33  {
34  return { InputPort<unsigned>(THRESHOLD_SUCCESS, "number of childen which need to succeed to trigger a SUCCESS" ),
35  InputPort<unsigned>(THRESHOLD_FAILURE, 1, "number of childen which need to fail to trigger a FAILURE" ) };
36  }
37 
38  ~ParallelNode() = default;
39 
40  virtual void halt() override;
41 
42  unsigned int thresholdM();
43  unsigned int thresholdFM();
44  void setThresholdM(unsigned int threshold_M);
45  void setThresholdFM(unsigned int threshold_M);
46 
47  private:
48  unsigned int success_threshold_;
49  unsigned int failure_threshold_;
50 
51  std::set<int> skip_list_;
52 
54  static constexpr const char* THRESHOLD_SUCCESS = "success_threshold";
55  static constexpr const char* THRESHOLD_FAILURE = "failure_threshold";
56 
57  virtual BT::NodeStatus tick() override;
58 };
59 
60 }
61 #endif // PARALLEL_NODE_H
unsigned int thresholdM()
const std::string & name() const
Name of the instance, not the type.
Definition: tree_node.cpp:73
const NodeConfiguration & config() const
Definition: tree_node.cpp:99
void setThresholdFM(unsigned int threshold_M)
static constexpr const char * THRESHOLD_SUCCESS
Definition: parallel_node.h:54
unsigned int success_threshold_
Definition: parallel_node.h:48
static constexpr const char * THRESHOLD_FAILURE
Definition: parallel_node.h:55
std::set< int > skip_list_
Definition: parallel_node.h:51
bool read_parameter_from_ports_
Definition: parallel_node.h:53
void setThresholdM(unsigned int threshold_M)
virtual void halt() override
unsigned int thresholdFM()
unsigned int failure_threshold_
Definition: parallel_node.h:49
std::unordered_map< std::string, PortInfo > PortsList
Definition: basic_types.h:317
ParallelNode(const std::string &name, unsigned success_threshold, unsigned failure_threshold=1)
virtual BT::NodeStatus tick() override
Method to be implemented by the user.
NodeStatus
Definition: basic_types.h:35
~ParallelNode()=default
static PortsList providedPorts()
Definition: parallel_node.h:32


behaviotree_cpp_v3
Author(s): Michele Colledanchise, Davide Faconti
autogenerated on Tue May 4 2021 02:56:25