19 #include "nav2_behavior_tree/plugins/control/pipeline_sequence.hpp"
21 namespace nav2_behavior_tree
25 : BT::ControlNode(name, {})
30 const std::string & name,
31 const BT::NodeConfiguration & config)
32 : BT::ControlNode(name, config)
38 unsigned skipped_count = 0;
39 for (std::size_t i = 0; i < children_nodes_.size(); ++i) {
40 auto status = children_nodes_[i]->executeTick();
42 case BT::NodeStatus::FAILURE:
43 ControlNode::haltChildren();
44 last_child_ticked_ = 0;
46 case BT::NodeStatus::SKIPPED:
50 case BT::NodeStatus::SUCCESS:
54 case BT::NodeStatus::RUNNING:
55 if (i >= last_child_ticked_) {
56 last_child_ticked_ = i;
62 std::stringstream error_msg;
63 error_msg <<
"Invalid node status. Received status " << status <<
64 "from child " << children_nodes_[i]->name();
65 throw std::runtime_error(error_msg.str());
69 ControlNode::haltChildren();
70 last_child_ticked_ = 0;
71 if (skipped_count == children_nodes_.size()) {
73 return BT::NodeStatus::SKIPPED;
75 return BT::NodeStatus::SUCCESS;
80 BT::ControlNode::halt();
81 last_child_ticked_ = 0;
86 BT_REGISTER_NODES(factory)
Type of sequence node that re-ticks previous children when a child returns running.
void halt() override
The other (optional) override required by a BT action to reset node state.
BT::NodeStatus tick() override
The main override required by a BT action.
PipelineSequence(const std::string &name)
A constructor for nav2_behavior_tree::PipelineSequence.