Closed
Description
Describe the bug
Sequence should always return child status if it is not skipped, however if previous state of sequence was SKIPPED, then the tree returns SKIPPED instead of child actual state. This used to work with release 4.6.2
How to Reproduce
Simple code that illustrates the issue (I wanted to attach a file, but "File type not allowed: .cpp").
#include "behaviortree_cpp/bt_factory.h"
int main(int argc, char ** argv)
{
const std::string xml_text = R"(
<root BTCPP_format="4" >
<BehaviorTree ID="MainTree">
<Sequence>
<AlwaysSuccess _skipIf="skip"/>
</Sequence>
</BehaviorTree>
</root>)";
auto factory = BT::BehaviorTreeFactory();
auto tree = factory.createTreeFromText(xml_text);
tree.rootBlackboard()->set("skip", true);
auto status = tree.tickWhileRunning();
std::cout << "Tree status: " << status << std::endl;
tree.rootBlackboard()->set("skip", false);
status = tree.tickWhileRunning();
std::cout << "Tree status: " << status << std::endl;
tree.rootBlackboard()->set("skip", true);
status = tree.tickWhileRunning();
std::cout << "Tree status: " << status << std::endl;
tree.rootBlackboard()->set("skip", false);
status = tree.tickWhileRunning();
std::cout << "Tree status: " << status << std::endl;
}
Compiled with (paths may be different if installed with apt):
g++ sequence_skip_bug.cpp -o sequence_skip_bug -I$HOME/ros2_ws/install/behaviortree_cpp/include -L$HOME/ros2_ws/install/behaviortree_cpp/lib -lbehaviortree_cpp
Expected output (and this is the output when compiled with version 4.6.2):
Tree status: SKIPPED
Tree status: SUCCESS
Tree status: SKIPPED
Tree status: SUCCESS
Actual output:
Tree status: SKIPPED
Tree status: SKIPPED
Tree status: SUCCESS
Tree status: SUCCESS
Problem seems to be related to skipped state only, I've tested it for _failureIf
instead of _skipIf
and it worked as expected. Probably related to this, but I'm not sure: 957a7f8
Metadata
Metadata
Assignees
Labels
No labels