examples
ex03_ncurses_manual_selector.cpp
Go to the documentation of this file.
1
#include "
behaviortree_cpp/bt_factory.h
"
2
#include "
dummy_nodes.h
"
3
4
using namespace
BT
;
5
6
/* Try also
7
* <ManualSelector repeat_last_selection="1">
8
* to see the difference.
9
*/
10
11
// clang-format off
12
static
const
char
*
xml_text
= R
"(
13
<root BTCPP_format="4" >
14
<BehaviorTree ID="MainTree">
15
<Repeat num_cycles="3">
16
<ManualSelector repeat_last_selection="0">
17
<SaySomething name="Option1" message="Option1" />
18
<SaySomething name="Option2" message="Option2" />
19
<SaySomething name="Option3" message="Option3" />
20
<SaySomething name="Option4" message="Option4" />
21
<ManualSelector name="YouChoose" />
22
</ManualSelector>
23
</Repeat>
24
</BehaviorTree>
25
</root>
26
)";
27
// clang-format on
28
29
int
main
()
30
{
31
BehaviorTreeFactory
factory;
32
factory.
registerNodeType
<
DummyNodes::SaySomething
>(
"SaySomething"
);
33
34
auto
tree = factory.
createTreeFromText
(
xml_text
);
35
auto
ret = tree.tickWhileRunning();
36
37
std::cout <<
"Result: "
<< ret << std::endl;
38
39
return
0;
40
}
BT
Definition:
ex01_wrap_legacy.cpp:29
bt_factory.h
dummy_nodes.h
BT::BehaviorTreeFactory::registerNodeType
void registerNodeType(const std::string &ID, const PortsList &ports, ExtraArgs... args)
Definition:
bt_factory.h:326
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
DummyNodes::SaySomething
Definition:
dummy_nodes.h:47
BT::BehaviorTreeFactory
The BehaviorTreeFactory is used to create instances of a TreeNode at run-time.
Definition:
bt_factory.h:209
main
int main()
Definition:
ex03_ncurses_manual_selector.cpp:29
xml_text
static const char * xml_text
Definition:
ex03_ncurses_manual_selector.cpp:12
behaviortree_cpp_v4
Author(s): Davide Faconti
autogenerated on Fri Dec 13 2024 03:19:16