2
3
4
5
6
7
8
9
10
11
15#include "behaviortree_cpp/decorator_node.h"
16#include "behaviortree_cpp/scripting/script_parser.hpp"
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
41 PreconditionNode(
const std::string& name,
const NodeConfig& config)
47 ~PreconditionNode()
override =
default;
54 static PortsList providedPorts()
56 return { InputPort<std::string>(
"if"),
58 "Return status if condition is "
68 if(!getInput(
"else", else_return))
70 throw RuntimeError(
"Missing parameter [else] in Precondition");
74 Ast::
Environment env = { config().blackboard, config().enums };
76 _children_running || (_children_running = _executor(env).cast<
bool>());
84 if(isStatusCompleted(child_status))
87 _children_running =
false;
95 if(!getInput(
"if", script))
97 throw RuntimeError(
"Missing parameter [if] in Precondition");
103 auto executor = ParseScript(script);
106 throw RuntimeError(executor.error());
110 _executor = executor.value();
116 ScriptFunction _executor;
117 bool _children_running =
false;
The DecoratorNode is the base class for nodes that have exactly one child.
Definition: decorator_node.h:19
The PreconditionNode evaluates a script condition before ticking its child.
Definition: script_precondition.h:39
virtual BT::NodeStatus executeTick()
The method that should be used to invoke tick() and setStatus();.
Definition: action_node.h:24
NodeStatus
Definition: basic_types.h:34
The Environment class is used to encapsulate the information and states needed by the scripting langu...
Definition: script_parser.hpp:32
Definition: tree_node.h:105