Nav2 Navigation Stack - lyrical  lyrical
ROS 2 Navigation Stack
round_robin_node.hpp
1 // Copyright (c) 2019 Intel Corporation
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef NAV2_BEHAVIOR_TREE__PLUGINS__CONTROL__ROUND_ROBIN_NODE_HPP_
16 #define NAV2_BEHAVIOR_TREE__PLUGINS__CONTROL__ROUND_ROBIN_NODE_HPP_
17 
18 #include <string>
19 
20 #include "behaviortree_cpp/control_node.h"
21 #include "behaviortree_cpp/bt_factory.h"
22 
23 namespace nav2_behavior_tree
24 {
25 
59 class RoundRobinNode : public BT::ControlNode
60 {
61 public:
66  explicit RoundRobinNode(const std::string & name);
67 
73  RoundRobinNode(const std::string & name, const BT::NodeConfiguration & config);
74 
79  BT::NodeStatus tick() override;
80 
84  void halt() override;
85 
90  static BT::PortsList providedPorts()
91  {
92  return {
93  BT::InputPort<bool>("wrap_around", false,
94  "Enable wrap-around to first child after last child fails")
95  };
96  }
97 
98 private:
99  unsigned int current_child_idx_{0};
100  unsigned int num_failed_children_{0};
101  bool wrap_around_{false};
102 };
103 
104 } // namespace nav2_behavior_tree
105 
106 #endif // NAV2_BEHAVIOR_TREE__PLUGINS__CONTROL__ROUND_ROBIN_NODE_HPP_
Type of sequence node that ticks children in a round-robin fashion.
void halt() override
The other (optional) override required by a BT action to reset node state.
static BT::PortsList providedPorts()
Creates list of BT ports.
BT::NodeStatus tick() override
The main override required by a BT action.
RoundRobinNode(const std::string &name)
A constructor for nav2_behavior_tree::RoundRobinNode.