sequence_node.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2015-2018 Michele Colledanchise - All Rights Reserved
2  * Copyright (C) 2018 Davide Faconti - 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 
15 
16 namespace BT
17 {
18 SequenceNode::SequenceNode(const std::string& name)
20 {
21  setRegistrationName("Sequence");
22 }
23 
25 {
26  const unsigned children_count = children_nodes_.size();
27 
29 
30  for (unsigned int index = 0; index < children_count; index++)
31  {
32  TreeNode* child_node = children_nodes_[index];
33  const NodeStatus child_status = child_node->executeTick();
34 
35  switch (child_status)
36  {
38  {
39  return child_status;
40  }
42  {
43  haltChildren(0);
44  return child_status;
45  }
47  {
48  // continue;
49  }
50  break;
51 
52  case NodeStatus::IDLE:
53  {
54  throw std::runtime_error("This is not supposed to happen");
55  }
56  } // end switch
57  } // end for loop
58 
59  haltChildren(0);
60  return NodeStatus::SUCCESS;
61 }
62 }
std::vector< TreeNode * > children_nodes_
Definition: control_node.h:26
virtual BT::NodeStatus tick() override
Method to be implemented by the user.
void setRegistrationName(const std::string &registration_name)
registrationName() is set by the BehaviorTreeFactory
Definition: tree_node.cpp:113
void haltChildren(int i)
std::unordered_map< std::string, std::string > NodeParameters
Definition: tree_node.h:33
SequenceNode(const std::string &name)
NodeStatus
Definition: basic_types.h:28
virtual BT::NodeStatus executeTick()
The method that will be executed to invoke tick(); and setStatus();.
Definition: tree_node.cpp:35
void setStatus(NodeStatus new_status)
Definition: tree_node.cpp:43


behaviortree_cpp
Author(s): Michele Colledanchise, Davide Faconti
autogenerated on Sun Feb 3 2019 03:14:32