Go to the documentation of this file.
17 return x ==
p.x &&
y ==
p.y;
28 add_field(
"x", &point.x);
29 add_field(
"y", &point.y);
40 return convertFromJSON<Point2D>(str);
47 int x = convertFromString<int>(parts[0]);
48 int y = convertFromString<int>(parts[1]);
65 Point2D pointA, pointB, pointC, pointD, pointE, input;
67 if(!getInput(
"pointA", pointA) || pointA !=
Point2D{ 1, 2 })
69 throw std::runtime_error(
"failed pointA");
71 if(!getInput(
"pointB", pointB) || pointB !=
Point2D{ 3, 4 })
73 throw std::runtime_error(
"failed pointB");
75 if(!getInput(
"pointC", pointC) || pointC !=
Point2D{ 5, 6 })
77 throw std::runtime_error(
"failed pointC");
79 if(!getInput(
"pointD", pointD) || pointD !=
Point2D{ 7, 8 })
81 throw std::runtime_error(
"failed pointD");
83 if(!getInput(
"pointE", pointE) || pointE !=
Point2D{ 9, 10 })
85 throw std::runtime_error(
"failed pointE");
87 if(!getInput(
"input", input) || input !=
Point2D{ -1, -2 })
89 throw std::runtime_error(
"failed input");
96 return { BT::InputPort<Point2D>(
"input",
"no default value"),
97 BT::InputPort<Point2D>(
"pointA",
Point2D{ 1, 2 },
"default value is [1,2]"),
98 BT::InputPort<Point2D>(
"pointB",
"{point}",
99 "default value inside blackboard {point}"),
100 BT::InputPort<Point2D>(
"pointC",
"5,6",
"default value is [5,6]"),
101 BT::InputPort<Point2D>(
"pointD",
"{=}",
102 "default value inside blackboard {pointD}"),
103 BT::InputPort<Point2D>(
"pointE", R
"(json:{"x":9,"y":10})",
104 "default value is [9,10]") };
110 std::string xml_txt = R
"(
111 <root BTCPP_format="4" >
113 <NodeWithDefaultPoints input="-1,-2"/>
121 auto tree = factory.createTreeFromText(xml_txt);
123 tree.subtrees.front()->blackboard->set<
Point2D>(
"point",
Point2D{ 3, 4 });
124 tree.subtrees.front()->blackboard->set<
Point2D>(
"pointD",
Point2D{ 7, 8 });
127 std::cout <<
"Result: " <<
toStr(status) << std::endl;
NodeStatus tick() override
Method to be implemented by the user.
bool operator==(const Point2D &p) const
std::string_view StringView
bool operator!=(const Point2D &p) const
static PortsList providedPorts()
NodeWithDefaultPoints(const std::string &name, const NodeConfig &config)
std::unordered_map< std::string, PortInfo > PortsList
BT_JSON_CONVERTER(Point2D, point)
void registerNodeType(const std::string &ID, const PortsList &ports, ExtraArgs... args)
std::vector< StringView > splitString(const StringView &strToSplit, char delimeter)
static JsonExporter & get()
The BehaviorTreeFactory is used to create instances of a TreeNode at run-time.
bool StartWith(StringView str, StringView prefix)
The SyncActionNode is an ActionNode that explicitly prevents the status RUNNING and doesn't require a...
constexpr auto p
Parses the production.
std::string toStr(const T &value)
toStr is the reverse operation of convertFromString.