-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Imported upstream version '3.8.6' of 'upstream'
- Loading branch information
1 parent
f43ad9c
commit 94c202c
Showing
11 changed files
with
265 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#include <gtest/gtest.h> | ||
#include "behaviortree_cpp_v3/bt_factory.h" | ||
#include "test_helper.hpp" | ||
#include "behaviortree_cpp_v3/loggers/bt_cout_logger.h" | ||
|
||
using BT::NodeStatus; | ||
using std::chrono::milliseconds; | ||
|
||
class SleepNode : public BT::StatefulActionNode | ||
{ | ||
public: | ||
|
||
SleepNode(const std::string& name, const BT::NodeConfiguration& config): | ||
StatefulActionNode(name, config) {} | ||
|
||
NodeStatus onStart() override { | ||
count_ = 0; | ||
return NodeStatus::RUNNING; | ||
} | ||
|
||
NodeStatus onRunning() override { | ||
return ++count_ < 10 ? NodeStatus::RUNNING : NodeStatus::SUCCESS; | ||
} | ||
|
||
void onHalted() override {} | ||
|
||
static BT::PortsList providedPorts(){ | ||
return {}; | ||
} | ||
|
||
private: | ||
int count_ = 0; | ||
}; | ||
|
||
|
||
TEST(Reactive, TestLogging) | ||
{ | ||
using namespace BT; | ||
|
||
static const char* reactive_xml_text = R"( | ||
<root> | ||
<BehaviorTree ID="Main"> | ||
<ReactiveSequence> | ||
<TestA name="testA"/> | ||
<AlwaysSuccess name="success"/> | ||
<Sleep/> | ||
</ReactiveSequence> | ||
</BehaviorTree> | ||
</root> | ||
)"; | ||
|
||
BehaviorTreeFactory factory; | ||
|
||
factory.registerNodeType<SleepNode>("Sleep"); | ||
|
||
std::array<int, 1> counters; | ||
RegisterTestTick(factory, "Test", counters); | ||
|
||
auto tree = factory.createTreeFromText(reactive_xml_text); | ||
StdCoutLogger logger(tree); | ||
|
||
auto ret = tree.tickRootWhileRunning(); | ||
ASSERT_EQ(ret, NodeStatus::SUCCESS); | ||
|
||
int num_ticks = counters[0]; | ||
ASSERT_GE(num_ticks, 10); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.