2
3
4
5
6
7
8
9
10
11
12
16#include "behaviortree_cpp/condition_node.h"
17#include "behaviortree_cpp/scripting/script_parser.hpp"
22
23
24
28 ScriptCondition(
const std::string& name,
const NodeConfig& config)
31 setRegistrationID(
"ScriptCondition");
35 static PortsList providedPorts()
37 return { InputPort(
"code",
"Piece of code that can be parsed. Must return false or "
46 Ast::
Environment env = { config().blackboard, config().enums };
47 auto result = _executor(env);
48 return (result.cast<
bool>()) ? NodeStatus::SUCCESS : NodeStatus::FAILURE;
54 if(!getInput(
"code", script))
56 throw RuntimeError(
"Missing port [code] in ScriptCondition");
62 auto executor = ParseScript(script);
65 throw RuntimeError(executor.error());
69 _executor = executor.value();
75 ScriptFunction _executor;
The ConditionNode is a leaf node used to check a condition.
Definition: condition_node.h:32
Execute a script, and if the result is true, return SUCCESS, FAILURE otherwise.
Definition: script_condition.h:26
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