gtest_ports.cpp
Go to the documentation of this file.
1 #include <gtest/gtest.h>
5 
6 using namespace BT;
7 
9 {
10 public:
11  NodeWithPorts(const std::string& name, const NodeConfig& config)
12  : SyncActionNode(name, config)
13  {
14  std::cout << "ctor" << std::endl;
15  }
16 
17  NodeStatus tick() override
18  {
19  int val_A = 0;
20  int val_B = 0;
21  if(!getInput("in_port_A", val_A))
22  {
23  throw RuntimeError("missing input [in_port_A]");
24  }
25  if(!getInput("in_port_B", val_B))
26  {
27  throw RuntimeError("missing input [in_port_B]");
28  }
29 
30  if(val_A == 42 && val_B == 66)
31  {
32  return NodeStatus::SUCCESS;
33  }
34  return NodeStatus::FAILURE;
35  }
36 
38  {
39  return { BT::InputPort<int>("in_port_A", 42, "magic_number"),
40  BT::InputPort<int>("in_port_B") };
41  }
42 };
43 
44 TEST(PortTest, WrongNodeConfig)
45 {
46  NodeConfig config;
47  config.input_ports["in_port_A"] = "42";
48  // intentionally missing:
49  // config.input_ports["in_port_B"] = "69";
50  NodeWithPorts node("will_fail", config);
51  ASSERT_ANY_THROW(node.tick());
52 }
53 
54 TEST(PortTest, DefaultPorts)
55 {
56  std::string xml_txt = R"(
57  <root BTCPP_format="4" >
58  <BehaviorTree ID="MainTree">
59  <NodeWithPorts in_port_B="66" />
60  </BehaviorTree>
61  </root>)";
62 
63  BehaviorTreeFactory factory;
64  factory.registerNodeType<NodeWithPorts>("NodeWithPorts");
65  auto tree = factory.createTreeFromText(xml_txt);
66  NodeStatus status = tree.tickWhileRunning();
67  ASSERT_EQ(status, NodeStatus::SUCCESS);
68 }
69 
70 TEST(PortTest, MissingPort)
71 {
72  std::string xml_txt = R"(
73  <root BTCPP_format="4" >
74  <BehaviorTree ID="MainTree">
75  <NodeWithPorts/>
76  </BehaviorTree>
77  </root>)";
78 
79  BehaviorTreeFactory factory;
80  factory.registerNodeType<NodeWithPorts>("NodeWithPorts");
81  auto tree = factory.createTreeFromText(xml_txt);
82  ASSERT_ANY_THROW(tree.tickWhileRunning());
83 }
84 
85 TEST(PortTest, WrongPort)
86 {
87  std::string xml_txt = R"(
88  <root BTCPP_format="4" >
89  <BehaviorTree ID="MainTree">
90  <NodeWithPorts da_port="66" />
91  </BehaviorTree>
92  </root>)";
93 
94  BehaviorTreeFactory factory;
95  factory.registerNodeType<NodeWithPorts>("NodeWithPorts");
96 
97  EXPECT_ANY_THROW(auto tree = factory.createTreeFromText(xml_txt));
98 }
99 
100 TEST(PortTest, Descriptions)
101 {
102  std::string xml_txt = R"(
103  <root BTCPP_format="4" >
104  <BehaviorTree ID="MainTree" _description="this is my tree" >
105  <Sequence>
106  <NodeWithPorts name="first" in_port_B="66" _description="this is my action" />
107  <SubTree ID="mySubTree" name="second" _description="this is a subtree"/>
108  </Sequence>
109  </BehaviorTree>
110 
111  <BehaviorTree ID="mySubTree" _description="this is a subtree" >
112  <NodeWithPorts name="third" in_port_B="99" />
113  </BehaviorTree>
114 
115  </root>)";
116 
117  BehaviorTreeFactory factory;
118  factory.registerNodeType<NodeWithPorts>("NodeWithPorts");
119 
120  factory.registerBehaviorTreeFromText(xml_txt);
121  auto tree = factory.createTree("MainTree");
122 
123  NodeStatus status = tree.tickWhileRunning();
124  while(status == NodeStatus::RUNNING)
125  {
126  status = tree.tickWhileRunning();
127  }
128 
129  ASSERT_EQ(status, NodeStatus::FAILURE); // failure because in_port_B="99"
130 }
131 
132 struct MyType
133 {
134  std::string value;
135 };
136 
138 {
139 public:
140  NodeInPorts(const std::string& name, const NodeConfig& config)
141  : SyncActionNode(name, config)
142  {}
143 
144  NodeStatus tick() override
145  {
146  int val_A = 0;
147  MyType val_B;
148  if(getInput("int_port", val_A) && getInput("any_port", val_B))
149  {
150  return NodeStatus::SUCCESS;
151  }
152  return NodeStatus::FAILURE;
153  }
154 
156  {
157  return { BT::InputPort<int>("int_port"), BT::InputPort<MyType>("any_port") };
158  }
159 };
160 
162 {
163 public:
164  NodeOutPorts(const std::string& name, const NodeConfig& config)
165  : SyncActionNode(name, config)
166  {}
167 
168  NodeStatus tick() override
169  {
170  return NodeStatus::SUCCESS;
171  }
172 
174  {
175  return { BT::OutputPort<int>("int_port"), BT::OutputPort<MyType>("any_port") };
176  }
177 };
178 
179 TEST(PortTest, EmptyPort)
180 {
181  std::string xml_txt = R"(
182  <root BTCPP_format="4" >
183  <BehaviorTree ID="MainTree">
184  <Sequence>
185  <NodeInPorts int_port="{ip}" any_port="{ap}" />
186  <NodeOutPorts int_port="{ip}" any_port="{ap}" />
187  </Sequence>
188  </BehaviorTree>
189  </root>)";
190 
191  BehaviorTreeFactory factory;
192  factory.registerNodeType<NodeOutPorts>("NodeOutPorts");
193  factory.registerNodeType<NodeInPorts>("NodeInPorts");
194 
195  auto tree = factory.createTreeFromText(xml_txt);
196 
197  NodeStatus status = tree.tickWhileRunning();
198  // expect failure because port is not set yet
199  ASSERT_EQ(status, NodeStatus::FAILURE);
200 }
201 
203 {
204 public:
205  IllegalPorts(const std::string& name, const NodeConfig& config)
206  : SyncActionNode(name, config)
207  {}
208 
209  NodeStatus tick() override
210  {
211  return NodeStatus::SUCCESS;
212  }
213 
215  {
216  return { BT::InputPort<std::string>("name") };
217  }
218 };
219 
220 TEST(PortTest, IllegalPorts)
221 {
222  BehaviorTreeFactory factory;
223  ASSERT_ANY_THROW(factory.registerNodeType<IllegalPorts>("nope"));
224 }
225 
227 {
228 public:
229  ActionVectorDoubleIn(const std::string& name, const NodeConfig& config,
230  std::vector<double>* states)
231  : SyncActionNode(name, config), states_(states)
232  {}
233 
234  NodeStatus tick() override
235  {
236  getInput("states", *states_);
237  return NodeStatus::SUCCESS;
238  }
239 
241  {
242  return { BT::InputPort<std::vector<double>>("states") };
243  }
244 
245 private:
246  std::vector<double>* states_;
247 };
248 
249 TEST(PortTest, SubtreeStringInput_Issue489)
250 {
251  std::string xml_txt = R"(
252  <root BTCPP_format="4" >
253  <BehaviorTree ID="Main">
254  <SubTree ID="Subtree_A" states="3;7"/>
255  </BehaviorTree>
256 
257  <BehaviorTree ID="Subtree_A">
258  <ActionVectorDoubleIn states="{states}"/>
259  </BehaviorTree>
260  </root>)";
261 
262  std::vector<double> states;
263 
264  BehaviorTreeFactory factory;
265  factory.registerNodeType<ActionVectorDoubleIn>("ActionVectorDoubleIn", &states);
266 
267  factory.registerBehaviorTreeFromText(xml_txt);
268  auto tree = factory.createTree("Main");
269 
270  NodeStatus status = tree.tickWhileRunning();
271 
272  ASSERT_EQ(status, NodeStatus::SUCCESS);
273  ASSERT_EQ(2, states.size());
274  ASSERT_EQ(3, states[0]);
275  ASSERT_EQ(7, states[1]);
276 }
277 
279 {
280 public:
281  ActionVectorStringIn(const std::string& name, const NodeConfig& config,
282  std::vector<std::string>* states)
283  : SyncActionNode(name, config), states_(states)
284  {}
285 
286  NodeStatus tick() override
287  {
288  getInput("states", *states_);
289  return NodeStatus::SUCCESS;
290  }
291 
293  {
294  return { BT::InputPort<std::vector<std::string>>("states") };
295  }
296 
297 private:
298  std::vector<std::string>* states_;
299 };
300 
301 TEST(PortTest, SubtreeStringInput_StringVector)
302 {
303  std::string xml_txt = R"(
304  <root BTCPP_format="4" >
305  <BehaviorTree ID="Main">
306  <ActionVectorStringIn states="hello;world;with spaces"/>
307  </BehaviorTree>
308  </root>)";
309 
310  std::vector<std::string> states;
311 
312  BehaviorTreeFactory factory;
313  factory.registerNodeType<ActionVectorStringIn>("ActionVectorStringIn", &states);
314 
315  factory.registerBehaviorTreeFromText(xml_txt);
316  auto tree = factory.createTree("Main");
317 
318  NodeStatus status = tree.tickWhileRunning();
319 
320  ASSERT_EQ(status, NodeStatus::SUCCESS);
321  ASSERT_EQ(3, states.size());
322  ASSERT_EQ("hello", states[0]);
323  ASSERT_EQ("world", states[1]);
324  ASSERT_EQ("with spaces", states[2]);
325 }
326 
327 struct Point2D
328 {
329  int x = 0;
330  int y = 0;
331  bool operator==(const Point2D& other) const
332  {
333  return x == other.x && y == other.y;
334  }
335  bool operator!=(const Point2D& other) const
336  {
337  return !(*this == other);
338  }
339 };
340 
341 template <>
342 [[nodiscard]] Point2D BT::convertFromString<Point2D>(StringView str)
343 {
344  if(StartWith(str, "json:"))
345  {
346  str.remove_prefix(5);
347  return convertFromJSON<Point2D>(str);
348  }
349  const auto parts = BT::splitString(str, ',');
350  if(parts.size() != 2)
351  {
352  throw BT::RuntimeError("invalid input)");
353  }
354  int x = convertFromString<int>(parts[0]);
355  int y = convertFromString<int>(parts[1]);
356  return { x, y };
357 }
358 
359 template <>
360 [[nodiscard]] std::string BT::toStr<Point2D>(const Point2D& point)
361 {
362  return std::to_string(point.x) + "," + std::to_string(point.y);
363 }
364 
366 {
367  add_field("x", &point.x);
368  add_field("y", &point.y);
369 }
370 
372 {
373 public:
374  DefaultTestAction(const std::string& name, const NodeConfig& config)
375  : SyncActionNode(name, config)
376  {}
377 
378  NodeStatus tick() override
379  {
380  const int answer = getInput<int>("answer").value();
381  if(answer != 42)
382  {
383  return NodeStatus::FAILURE;
384  }
385 
386  const std::string greet = getInput<std::string>("greeting").value();
387  if(greet != "hello")
388  {
389  return NodeStatus::FAILURE;
390  }
391 
392  const Point2D point = getInput<Point2D>("pos").value();
393  if(point.x != 1 || point.y != 2)
394  {
395  return NodeStatus::FAILURE;
396  }
397 
398  return NodeStatus::SUCCESS;
399  }
400 
402  {
403  return { BT::InputPort<int>("answer", 42, "the answer"),
404  BT::InputPort<std::string>("greeting", "hello", "be polite"),
405  BT::InputPort<Point2D>("pos", Point2D{ 1, 2 }, "where") };
406  }
407 };
408 
409 TEST(PortTest, DefaultInput)
410 {
411  std::string xml_txt = R"(
412  <root BTCPP_format="4" >
413  <BehaviorTree>
414  <DefaultTestAction/>
415  </BehaviorTree>
416  </root>)";
417 
418  BehaviorTreeFactory factory;
419  factory.registerNodeType<DefaultTestAction>("DefaultTestAction");
420  auto tree = factory.createTreeFromText(xml_txt);
421  auto status = tree.tickOnce();
422  ASSERT_EQ(status, NodeStatus::SUCCESS);
423 }
424 
425 class GetAny : public SyncActionNode
426 {
427 public:
428  GetAny(const std::string& name, const NodeConfig& config) : SyncActionNode(name, config)
429  {}
430 
431  NodeStatus tick() override
432  {
433  // case 1: the port is Any, but we can cast dirrectly to string
434  auto res_str = getInput<std::string>("val_str");
435  // case 2: the port is Any, and we retrieve an Any (to be casted later)
436  auto res_int = getInput<BT::Any>("val_int");
437 
438  // case 3: port is double and we get a double
439  auto res_real_A = getInput<double>("val_real");
440  // case 4: port is double and we get an Any
441  auto res_real_B = getInput<BT::Any>("val_real");
442 
443  bool expected = res_str.value() == "hello" && res_int->cast<int>() == 42 &&
444  res_real_A.value() == 3.14 && res_real_B->cast<double>() == 3.14;
445 
446  return expected ? NodeStatus::SUCCESS : NodeStatus::FAILURE;
447  }
448 
450  {
451  return { BT::InputPort<BT::Any>("val_str"), BT::InputPort<BT::Any>("val_int"),
452  BT::InputPort<double>("val_real") };
453  }
454 };
455 
456 class SetAny : public SyncActionNode
457 {
458 public:
459  SetAny(const std::string& name, const NodeConfig& config) : SyncActionNode(name, config)
460  {}
461 
462  NodeStatus tick() override
463  {
464  // check that the port can contain different types
465  setOutput("val_str", BT::Any(1.0));
466  setOutput("val_str", BT::Any(1));
467  setOutput("val_str", BT::Any("hello"));
468 
469  setOutput("val_int", 42);
470  setOutput("val_real", 3.14);
471  return NodeStatus::SUCCESS;
472  }
473 
475  {
476  return { BT::OutputPort<BT::Any>("val_str"), BT::OutputPort<int>("val_int"),
477  BT::OutputPort<BT::Any>("val_real") };
478  }
479 };
480 
481 TEST(PortTest, AnyPort)
482 {
483  std::string xml_txt = R"(
484  <root BTCPP_format="4" >
485  <BehaviorTree>
486  <Sequence>
487  <SetAny val_str="{val_str}" val_int="{val_int}" val_real="{val_real}"/>
488  <GetAny val_str="{val_str}" val_int="{val_int}" val_real="{val_real}"/>
489  </Sequence>
490  </BehaviorTree>
491  </root>)";
492 
493  BehaviorTreeFactory factory;
494  factory.registerNodeType<SetAny>("SetAny");
495  factory.registerNodeType<GetAny>("GetAny");
496  auto tree = factory.createTreeFromText(xml_txt);
497  auto status = tree.tickOnce();
498  ASSERT_EQ(status, NodeStatus::SUCCESS);
499 }
500 
502 {
503 public:
504  NodeWithDefaultPoints(const std::string& name, const NodeConfig& config)
505  : SyncActionNode(name, config)
506  {}
507 
508  NodeStatus tick() override
509  {
510  Point2D pointA, pointB, pointC, pointD, pointE, input;
511 
512  if(!getInput("pointA", pointA) || pointA != Point2D{ 1, 2 })
513  {
514  throw std::runtime_error("failed pointA");
515  }
516  if(!getInput("pointB", pointB) || pointB != Point2D{ 3, 4 })
517  {
518  throw std::runtime_error("failed pointB");
519  }
520  if(!getInput("pointC", pointC) || pointC != Point2D{ 5, 6 })
521  {
522  throw std::runtime_error("failed pointC");
523  }
524  if(!getInput("pointD", pointD) || pointD != Point2D{ 7, 8 })
525  {
526  throw std::runtime_error("failed pointD");
527  }
528  if(!getInput("pointE", pointE) || pointE != Point2D{ 9, 10 })
529  {
530  throw std::runtime_error("failed pointE");
531  }
532  if(!getInput("input", input) || input != Point2D{ -1, -2 })
533  {
534  throw std::runtime_error("failed input");
535  }
536  return NodeStatus::SUCCESS;
537  }
538 
540  {
541  return { BT::InputPort<Point2D>("input", "no default value"),
542  BT::InputPort<Point2D>("pointA", Point2D{ 1, 2 }, "default value is [1,2]"),
543  BT::InputPort<Point2D>("pointB", "{point}",
544  "default value inside blackboard {point}"),
545  BT::InputPort<Point2D>("pointC", "5,6", "default value is [5,6]"),
546  BT::InputPort<Point2D>("pointD", "{=}",
547  "default value inside blackboard {pointD}"),
548  BT::InputPort<Point2D>("pointE", R"(json:{"x":9,"y":10})",
549  "default value is [9,10]") };
550  }
551 };
552 
553 TEST(PortTest, DefaultInputPoint2D)
554 {
555  std::string xml_txt = R"(
556  <root BTCPP_format="4" >
557  <BehaviorTree>
558  <NodeWithDefaultPoints input="-1,-2"/>
559  </BehaviorTree>
560  </root>)";
561 
563 
564  BehaviorTreeFactory factory;
565  factory.registerNodeType<NodeWithDefaultPoints>("NodeWithDefaultPoints");
566  auto tree = factory.createTreeFromText(xml_txt);
567 
568  tree.subtrees.front()->blackboard->set<Point2D>("point", Point2D{ 3, 4 });
569  tree.subtrees.front()->blackboard->set<Point2D>("pointD", Point2D{ 7, 8 });
570 
571  BT::NodeStatus status;
572  ASSERT_NO_THROW(status = tree.tickOnce());
573  ASSERT_EQ(status, NodeStatus::SUCCESS);
574 
575  std::cout << writeTreeNodesModelXML(factory) << std::endl;
576 }
577 
579 {
580 public:
581  NodeWithDefaultStrings(const std::string& name, const NodeConfig& config)
582  : SyncActionNode(name, config)
583  {}
584 
585  NodeStatus tick() override
586  {
587  std::string input, msgA, msgB, msgC;
588  if(!getInput("input", input) || input != "from XML")
589  {
590  throw std::runtime_error("failed input");
591  }
592  if(!getInput("msgA", msgA) || msgA != "hello")
593  {
594  throw std::runtime_error("failed msgA");
595  }
596  if(!getInput("msgB", msgB) || msgB != "ciao")
597  {
598  throw std::runtime_error("failed msgB");
599  }
600  if(!getInput("msgC", msgC) || msgC != "hola")
601  {
602  throw std::runtime_error("failed msgC");
603  }
604  return NodeStatus::SUCCESS;
605  }
606 
608  {
609  return { BT::InputPort<std::string>("input", "no default"),
610  BT::InputPort<std::string>("msgA", "hello", "default value is 'hello'"),
611  BT::InputPort<std::string>("msgB", "{msg}",
612  "default value inside blackboard {msg}"),
613  BT::InputPort<std::string>("msgC", "{=}",
614  "default value inside blackboard {msgC}") };
615  }
616 };
617 
618 TEST(PortTest, DefaultInputStrings)
619 {
620  std::string xml_txt = R"(
621  <root BTCPP_format="4" >
622  <BehaviorTree>
623  <NodeWithDefaultStrings input="from XML"/>
624  </BehaviorTree>
625  </root>)";
626 
627  BehaviorTreeFactory factory;
628  factory.registerNodeType<NodeWithDefaultStrings>("NodeWithDefaultStrings");
629  auto tree = factory.createTreeFromText(xml_txt);
630 
631  tree.subtrees.front()->blackboard->set<std::string>("msg", "ciao");
632  tree.subtrees.front()->blackboard->set<std::string>("msgC", "hola");
633 
634  BT::NodeStatus status;
635  ASSERT_NO_THROW(status = tree.tickOnce());
636  ASSERT_EQ(status, NodeStatus::SUCCESS);
637 
638  std::cout << writeTreeNodesModelXML(factory) << std::endl;
639 }
640 
642 {
643  int a;
644  double b;
645  std::string c;
646 };
647 
649 {
650 public:
651  NodeWithDefaultNullptr(const std::string& name, const NodeConfig& config)
652  : SyncActionNode(name, config)
653  {}
654 
655  NodeStatus tick() override
656  {
657  return NodeStatus::SUCCESS;
658  }
659 
661  {
662  return { BT::InputPort<std::shared_ptr<TestStruct>>("input", nullptr,
663  "default value is nullptr") };
664  }
665 };
666 
667 TEST(PortTest, Default_Issues_767)
668 {
669  using namespace BT;
670 
671  ASSERT_NO_THROW(auto p = InputPort<std::optional<Point2D>>("opt_A", std::nullopt,
672  "default nullopt"));
673  ASSERT_NO_THROW(auto p = InputPort<std::optional<std::string>>("opt_B", std::nullopt,
674  "default nullopt"));
675 
676  ASSERT_NO_THROW(
677  auto p = InputPort<std::shared_ptr<Point2D>>("ptr_A", nullptr, "default nullptr"));
678  ASSERT_NO_THROW(auto p = InputPort<std::shared_ptr<std::string>>("ptr_B", nullptr,
679  "default nullptr"));
680 }
681 
682 TEST(PortTest, DefaultWronglyOverriden)
683 {
684  BT::BehaviorTreeFactory factory;
685  factory.registerNodeType<NodeWithDefaultNullptr>("NodeWithDefaultNullptr");
686 
687  std::string xml_txt_wrong = R"(
688  <root BTCPP_format="4" >
689  <BehaviorTree>
690  <NodeWithDefaultNullptr input=""/>
691  </BehaviorTree>
692  </root>)";
693 
694  std::string xml_txt_correct = R"(
695  <root BTCPP_format="4" >
696  <BehaviorTree>
697  <NodeWithDefaultNullptr/>
698  </BehaviorTree>
699  </root>)";
700 
701  // this should throw, because we are NOT using the default,
702  // but overriding it with an empty string instead.
703  // See issue 768 for reference
704  ASSERT_ANY_THROW(auto tree = factory.createTreeFromText(xml_txt_wrong));
705  // This is correct
706  ASSERT_NO_THROW(auto tree = factory.createTreeFromText(xml_txt_correct));
707 }
NodeWithDefaultStrings
Definition: gtest_ports.cpp:578
BT
Definition: ex01_wrap_legacy.cpp:29
NodeWithDefaultNullptr::providedPorts
static PortsList providedPorts()
Definition: gtest_ports.cpp:660
NodeOutPorts::tick
NodeStatus tick() override
Method to be implemented by the user.
Definition: gtest_ports.cpp:168
DefaultTestAction::providedPorts
static PortsList providedPorts()
Definition: gtest_ports.cpp:401
NodeWithDefaultPoints::tick
NodeStatus tick() override
Method to be implemented by the user.
Definition: gtest_ports.cpp:508
BT::Any
Definition: safe_any.hpp:36
NodeWithDefaultStrings::tick
NodeStatus tick() override
Method to be implemented by the user.
Definition: gtest_ports.cpp:585
NodeWithDefaultNullptr::tick
NodeStatus tick() override
Method to be implemented by the user.
Definition: gtest_ports.cpp:655
BT::BehaviorTreeFactory::createTree
Tree createTree(const std::string &tree_name, Blackboard::Ptr blackboard=Blackboard::create())
Definition: bt_factory.cpp:432
NodeOutPorts::NodeOutPorts
NodeOutPorts(const std::string &name, const NodeConfig &config)
Definition: gtest_ports.cpp:164
SetAny::tick
NodeStatus tick() override
Method to be implemented by the user.
Definition: gtest_ports.cpp:462
BT::StringView
std::string_view StringView
Definition: basic_types.h:59
BT::InputPort
std::pair< std::string, PortInfo > InputPort(StringView name, StringView description={})
Definition: basic_types.h:470
TestStruct
Definition: gtest_ports.cpp:641
DefaultTestAction::tick
NodeStatus tick() override
Method to be implemented by the user.
Definition: gtest_ports.cpp:378
BT::NodeConfig::input_ports
PortsRemapping input_ports
Definition: tree_node.h:83
TEST
TEST(PortTest, WrongNodeConfig)
Definition: gtest_ports.cpp:44
IllegalPorts
Definition: gtest_ports.cpp:202
Point2D
Definition: t12_default_ports.cpp:11
GetAny::GetAny
GetAny(const std::string &name, const NodeConfig &config)
Definition: gtest_ports.cpp:428
NodeWithDefaultNullptr
Definition: gtest_ports.cpp:648
TestStruct::b
double b
Definition: gtest_ports.cpp:644
bt_factory.h
ActionVectorDoubleIn::states_
std::vector< double > * states_
Definition: gtest_ports.cpp:246
NodeWithDefaultPoints::providedPorts
static PortsList providedPorts()
Definition: gtest_ports.cpp:539
MyType
Definition: gtest_ports.cpp:132
NodeWithDefaultStrings::providedPorts
static PortsList providedPorts()
Definition: gtest_ports.cpp:607
ActionVectorStringIn
Definition: gtest_ports.cpp:278
NodeWithDefaultPoints::NodeWithDefaultPoints
NodeWithDefaultPoints(const std::string &name, const NodeConfig &config)
Definition: gtest_ports.cpp:504
GetAny::tick
NodeStatus tick() override
Method to be implemented by the user.
Definition: gtest_ports.cpp:431
ActionVectorStringIn::states_
std::vector< std::string > * states_
Definition: gtest_ports.cpp:298
BT::Tree::tickWhileRunning
NodeStatus tickWhileRunning(std::chrono::milliseconds sleep_time=std::chrono::milliseconds(10))
Definition: bt_factory.cpp:610
NodeWithPorts::tick
NodeStatus tick() override
Method to be implemented by the user.
Definition: gtest_ports.cpp:17
BT::PortsList
std::unordered_map< std::string, PortInfo > PortsList
Definition: basic_types.h:585
ActionVectorStringIn::providedPorts
static PortsList providedPorts()
Definition: gtest_ports.cpp:292
lexyd::nullopt
constexpr auto nullopt
Definition: option.hpp:50
SetAny::SetAny
SetAny(const std::string &name, const NodeConfig &config)
Definition: gtest_ports.cpp:459
TestStruct::a
int a
Definition: gtest_ports.cpp:643
ActionVectorDoubleIn::tick
NodeStatus tick() override
Method to be implemented by the user.
Definition: gtest_ports.cpp:234
BT::NodeStatus::FAILURE
@ FAILURE
GetAny::providedPorts
static PortsList providedPorts()
Definition: gtest_ports.cpp:449
NodeWithDefaultNullptr::NodeWithDefaultNullptr
NodeWithDefaultNullptr(const std::string &name, const NodeConfig &config)
Definition: gtest_ports.cpp:651
BT::BehaviorTreeFactory::registerNodeType
void registerNodeType(const std::string &ID, const PortsList &ports, ExtraArgs... args)
Definition: bt_factory.h:326
NodeInPorts
Definition: gtest_ports.cpp:137
BT::BehaviorTreeFactory::createTreeFromText
Tree createTreeFromText(const std::string &text, Blackboard::Ptr blackboard=Blackboard::create())
createTreeFromText will parse the XML directly from string. The XML needs to contain either a single ...
Definition: bt_factory.cpp:395
ActionVectorStringIn::ActionVectorStringIn
ActionVectorStringIn(const std::string &name, const NodeConfig &config, std::vector< std::string > *states)
Definition: gtest_ports.cpp:281
NodeInPorts::providedPorts
static PortsList providedPorts()
Definition: gtest_ports.cpp:155
ActionVectorDoubleIn::providedPorts
static PortsList providedPorts()
Definition: gtest_ports.cpp:240
ActionVectorDoubleIn
Definition: gtest_ports.cpp:226
BT::RuntimeError
Definition: exceptions.h:58
json_export.h
NodeInPorts::NodeInPorts
NodeInPorts(const std::string &name, const NodeConfig &config)
Definition: gtest_ports.cpp:140
NodeWithDefaultStrings::NodeWithDefaultStrings
NodeWithDefaultStrings(const std::string &name, const NodeConfig &config)
Definition: gtest_ports.cpp:581
BT::splitString
std::vector< StringView > splitString(const StringView &strToSplit, char delimeter)
Definition: basic_types.cpp:348
MyType::value
std::string value
Definition: gtest_ports.cpp:134
DefaultTestAction
Definition: gtest_ports.cpp:371
BT::JsonExporter::get
static JsonExporter & get()
Definition: json_export.cpp:6
to_string
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string(const NLOHMANN_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values
Definition: json.hpp:24456
xml_parsing.h
BT::BehaviorTreeFactory
The BehaviorTreeFactory is used to create instances of a TreeNode at run-time.
Definition: bt_factory.h:209
ActionVectorStringIn::tick
NodeStatus tick() override
Method to be implemented by the user.
Definition: gtest_ports.cpp:286
NodeInPorts::tick
NodeStatus tick() override
Method to be implemented by the user.
Definition: gtest_ports.cpp:144
BT::NodeStatus::SUCCESS
@ SUCCESS
NodeWithPorts
Definition: gtest_ports.cpp:8
NodeWithPorts::NodeWithPorts
NodeWithPorts(const std::string &name, const NodeConfig &config)
Definition: gtest_ports.cpp:11
BT::NodeStatus::RUNNING
@ RUNNING
NodeOutPorts::providedPorts
static PortsList providedPorts()
Definition: gtest_ports.cpp:173
TestStruct::c
std::string c
Definition: gtest_ports.cpp:645
BT::StartWith
bool StartWith(StringView str, StringView prefix)
Definition: basic_types.cpp:464
IllegalPorts::IllegalPorts
IllegalPorts(const std::string &name, const NodeConfig &config)
Definition: gtest_ports.cpp:205
BT::BehaviorTreeFactory::registerBehaviorTreeFromText
void registerBehaviorTreeFromText(const std::string &xml_text)
Definition: bt_factory.cpp:277
NodeWithDefaultPoints
Definition: t12_default_ports.cpp:55
SetAny::providedPorts
static PortsList providedPorts()
Definition: gtest_ports.cpp:474
BT_JSON_CONVERTER
BT_JSON_CONVERTER(Point2D, point)
Definition: gtest_ports.cpp:365
SetAny
Definition: gtest_ports.cpp:456
NodeWithPorts::providedPorts
static PortsList providedPorts()
Definition: gtest_ports.cpp:37
IllegalPorts::tick
NodeStatus tick() override
Method to be implemented by the user.
Definition: gtest_ports.cpp:209
BT::JsonExporter::addConverter
void addConverter()
Definition: json_export.h:130
ActionVectorDoubleIn::ActionVectorDoubleIn
ActionVectorDoubleIn(const std::string &name, const NodeConfig &config, std::vector< double > *states)
Definition: gtest_ports.cpp:229
Point2D::operator==
bool operator==(const Point2D &other) const
Definition: gtest_ports.cpp:331
Point2D::x
int x
Definition: t12_default_ports.cpp:13
Point2D::operator!=
bool operator!=(const Point2D &other) const
Definition: gtest_ports.cpp:335
BT::NodeConfig
Definition: tree_node.h:73
DefaultTestAction::DefaultTestAction
DefaultTestAction(const std::string &name, const NodeConfig &config)
Definition: gtest_ports.cpp:374
IllegalPorts::providedPorts
static PortsList providedPorts()
Definition: gtest_ports.cpp:214
NodeOutPorts
Definition: gtest_ports.cpp:161
BT::SyncActionNode
The SyncActionNode is an ActionNode that explicitly prevents the status RUNNING and doesn't require a...
Definition: action_node.h:52
Point2D::y
int y
Definition: t12_default_ports.cpp:14
BT::NodeStatus
NodeStatus
Definition: basic_types.h:33
BT::writeTreeNodesModelXML
std::string writeTreeNodesModelXML(const BehaviorTreeFactory &factory, bool include_builtin=false)
writeTreeNodesModelXML generates an XMl that contains the manifests in the <TreeNodesModel>
Definition: xml_parsing.cpp:1214
lexyd::p
constexpr auto p
Parses the production.
Definition: production.hpp:127
GetAny
Definition: gtest_ports.cpp:425


behaviortree_cpp_v4
Author(s): Davide Faconti
autogenerated on Fri Dec 13 2024 03:19:16