BehaviorTree
Core Library to create and execute Behavior Trees
Loading...
Searching...
No Matches
manual_node.h
1/* Copyright (C) 2020-2025 Davide Faconti - All Rights Reserved
2*
3* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
4* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
5* 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:
6* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7*
8* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9* 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,
10* 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.
11*/
12
13#pragma once
14
15#include "behaviortree_cpp/control_node.h"
16
17namespace BT
18{
19/**
20 * @brief Use a Terminal User Interface (ncurses) to select a certain child manually.
21 */
23{
24public:
25 ManualSelectorNode(const std::string& name, const NodeConfig& config);
26
27 ~ManualSelectorNode() override = default;
28
29 ManualSelectorNode(const ManualSelectorNode&) = delete;
30 ManualSelectorNode& operator=(const ManualSelectorNode&) = delete;
31 ManualSelectorNode(ManualSelectorNode&&) = delete;
32 ManualSelectorNode& operator=(ManualSelectorNode&&) = delete;
33
34 virtual void halt() override;
35
36 static PortsList providedPorts()
37 {
38 return { InputPort<bool>(REPEAT_LAST_SELECTION, false,
39 "If true, execute again the same child that was selected "
40 "the "
41 "last "
42 "time") };
43 }
44
45private:
46 static constexpr const char* REPEAT_LAST_SELECTION = "repeat_last_selection";
47
48 virtual BT::NodeStatus tick() override;
49 int running_child_idx_;
50 int previously_executed_idx_;
51
52 enum NumericalStatus
53 {
54 NUM_SUCCESS = 253,
55 NUM_FAILURE = 254,
56 NUM_RUNNING = 255,
57 };
58
59 NodeStatus selectStatus() const;
60
61 uint8_t selectChild() const;
62};
63
64} // namespace BT
The ControlNode is the base class for nodes that can have multiple children.
Definition: control_node.h:32
Use a Terminal User Interface (ncurses) to select a certain child manually.
Definition: manual_node.h:23
virtual void halt() override
Definition: action_node.h:24
NodeStatus
Definition: basic_types.h:34
Definition: tree_node.h:105