BehaviorTree
Core Library to create and execute Behavior Trees
Loading...
Searching...
No Matches
sequence_with_memory_node.h
1/* Copyright (C) 2015-2018 Michele Colledanchise - All Rights Reserved
2 * Copyright (C) 2018-2025 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 "behaviortree_cpp/control_node.h"
17
18namespace BT
19{
20/**
21 * @brief The SequenceWithMemory is used to tick children in an ordered sequence.
22 * If any child returns RUNNING, previous children are not ticked again.
23 *
24 * - If all the children return SUCCESS, this node returns SUCCESS.
25 *
26 * - If a child returns RUNNING, this node returns RUNNING.
27 * Loop is NOT restarted, the same running child will be ticked again.
28 *
29 * - If a child returns FAILURE, stop the loop and return FAILURE.
30 * Loop is NOT restarted, the same running child will be ticked again.
31 *
32 */
33
35{
36public:
37 SequenceWithMemory(const std::string& name);
38
39 ~SequenceWithMemory() override = default;
40
41 SequenceWithMemory(const SequenceWithMemory&) = delete;
42 SequenceWithMemory& operator=(const SequenceWithMemory&) = delete;
43 SequenceWithMemory(SequenceWithMemory&&) = delete;
44 SequenceWithMemory& operator=(SequenceWithMemory&&) = delete;
45
46 virtual void halt() override;
47
48private:
49 size_t current_child_idx_;
50 size_t skipped_count_ = 0;
51
52 virtual BT::NodeStatus tick() override;
53};
54
55} // namespace BT
The ControlNode is the base class for nodes that can have multiple children.
Definition: control_node.h:32
The SequenceWithMemory is used to tick children in an ordered sequence. If any child returns RUNNING,...
Definition: sequence_with_memory_node.h:35
virtual void halt() override
Definition: action_node.h:24
NodeStatus
Definition: basic_types.h:34