Go to the documentation of this file. 1 #include <gtest/gtest.h>
15 std::string port_name)
37 std::string port_name)
66 TEST(ReactiveBackchaining, EnsureWarm)
72 <root BTCPP_format="4">
73 <BehaviorTree ID="EnsureWarm">
77 <IsHoldingJacket name="jacket" />
78 <WearJacket name="wear" />
95 auto& blackboard = tree.subtrees.front()->blackboard;
96 blackboard->set(
"is_warm",
false);
97 blackboard->set(
"holding_jacket",
true);
101 EXPECT_FALSE(blackboard->get<
bool>(
"is_warm"));
105 EXPECT_FALSE(blackboard->get<
bool>(
"is_warm"));
109 EXPECT_TRUE(blackboard->get<
bool>(
"is_warm"));
123 TEST(ReactiveBackchaining, EnsureWarmWithEnsureHoldingHacket)
128 <root BTCPP_format="4">
129 <BehaviorTree ID="EnsureWarm">
133 <SubTree ID="EnsureHoldingJacket" />
139 <BehaviorTree ID="EnsureHoldingJacket">
162 tree.
subtrees[0]->blackboard->set(
"is_warm",
false);
163 tree.
subtrees[1]->blackboard->set(
"holding_jacket",
false);
164 tree.
subtrees[1]->blackboard->set(
"near_closet",
true);
168 EXPECT_FALSE(tree.
subtrees[0]->blackboard->get<
bool>(
"is_warm"));
169 EXPECT_FALSE(tree.
subtrees[1]->blackboard->get<
bool>(
"holding_jacket"));
170 EXPECT_TRUE(tree.
subtrees[1]->blackboard->get<
bool>(
"near_closet"));
177 EXPECT_FALSE(tree.
subtrees[0]->blackboard->get<
bool>(
"is_warm"));
178 EXPECT_TRUE(tree.
subtrees[1]->blackboard->get<
bool>(
"holding_jacket"));
185 EXPECT_TRUE(tree.
subtrees[0]->blackboard->get<
bool>(
"is_warm"));
Tree createTree(const std::string &tree_name, Blackboard::Ptr blackboard=Blackboard::create())
const NodeConfig & config() const
const NodeStatistics & getStatistics(const std::string &path) const
NodeStatus onStart() override
Struct used to store a tree. If this object goes out of scope, the tree is destroyed.
unsigned transitions_count
Blackboard::Ptr blackboard
std::unordered_map< std::string, PortInfo > PortsList
void registerNodeType(const std::string &ID, const PortsList &ports, ExtraArgs... args)
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 ...
NodeStatus tickExactlyOnce()
BT::NodeStatus tick() override
Method to be implemented by the user.
TEST(ReactiveBackchaining, EnsureWarm)
The BehaviorTreeFactory is used to create instances of a TreeNode at run-time.
The TreeObserver is used to collect statistics about which nodes are executed and their returned stat...
const std::string & name() const
Name of the instance, not the type.
std::vector< Subtree::Ptr > subtrees
NodeStatus onRunning() override
method invoked when the action is already in the RUNNING state.
void registerBehaviorTreeFromText(const std::string &xml_text)
static BT::PortsList providedPorts()
SimpleCondition(const std::string &name, const BT::NodeConfig &config, std::string port_name)
AsyncTestAction(const std::string &name, const BT::NodeConfig &config, std::string port_name)
static const char * xml_text
static BT::PortsList providedPorts()
The StatefulActionNode is the preferred way to implement asynchronous Actions. It is actually easier ...