Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion nav2_behavior_tree/plugins/control/persistent_sequence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ BT::NodeStatus PersistentSequenceNode::tick()
const int children_count = children_nodes_.size();

int current_child_idx;
getInput("current_child_idx", current_child_idx);
if (!getInput("current_child_idx", current_child_idx)) {
throw BT::RuntimeError(
"Missing required input [current_child_idx] in PersistentSequenceNode. "
"Set via <Script code=\"current_child_idx := 0\" />");
}

setStatus(BT::NodeStatus::RUNNING);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,23 @@ std::shared_ptr<BT::BehaviorTreeFactory>
PersistentSequenceTestFixture::factory_ = nullptr;
std::shared_ptr<BT::Tree> PersistentSequenceTestFixture::tree_ = nullptr;

TEST_F(PersistentSequenceTestFixture, test_empty_fails)
{
// create tree
std::string xml_txt =
R"(
<root BTCPP_format="4">
<BehaviorTree ID="MainTree">
<PersistentSequence>
<AlwaysSuccess/>
</PersistentSequence>
</BehaviorTree>
</root>)";
tree_ = std::make_shared<BT::Tree>(factory_->createTreeFromText(xml_txt, config_->blackboard));

EXPECT_THROW(tree_->rootNode()->executeTick(), BT::RuntimeError);
}

TEST_F(PersistentSequenceTestFixture, test_tick)
{
// create tree
Expand Down
Loading