Skip to content

Commit 43075b5

Browse files
committed
bug fix #601: onHalted not called correctly in Control Nodes
1 parent b9906d1 commit 43075b5

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/control_node.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ void ControlNode::resetChildren()
4040
{
4141
if (child->status() == NodeStatus::RUNNING)
4242
{
43-
child->halt();
43+
child->haltNode();
4444
}
4545
child->resetStatus();
4646
}

tests/gtest_postconditions.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,29 @@ TEST(PostConditions, Issue539)
6161
ASSERT_EQ(tree.rootBlackboard()->get<int>("y"), 5);
6262
}
6363

64+
TEST(PostConditions, Issue601)
65+
{
66+
const std::string xml_text = R"(
67+
<root BTCPP_format="4" >
68+
<BehaviorTree ID="test_tree">
69+
<Sequence>
70+
<Script code="test := 'start'"/>
71+
<Parallel failure_count="1"
72+
success_count="-1">
73+
<Sleep msec="1000"
74+
_onHalted="test = 'halted'"
75+
_post="test = 'post'"/>
76+
<AlwaysFailure/>
77+
</Parallel>
78+
</Sequence>
79+
</BehaviorTree>
80+
</root>)";
81+
82+
BehaviorTreeFactory factory;
83+
auto tree = factory.createTreeFromText(xml_text);
84+
const auto status = tree.tickWhileRunning();
85+
86+
ASSERT_EQ(tree.rootBlackboard()->get<std::string>("test"), "halted");
87+
}
88+
6489

0 commit comments

Comments
 (0)