Skip to content

"ReactiveSequence is not supposed to reach this point" happens when some children are skipped #515

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
torydebra opened this issue Mar 7, 2023 · 3 comments

Comments

@torydebra
Copy link

torydebra commented Mar 7, 2023

Hi,
I am using a ReactiveSequence with _skipIf preconditions on the children, and it throws:

terminate called after throwing an instance of 'BT::LogicError'
  what():  ReactiveSequence is not supposed to reach this point

Looking at the code

case NodeStatus::SKIPPED: {
// node skipped
}
break;
case NodeStatus::IDLE: {
throw LogicError("[", name(), "]: A children should not return IDLE");
}
} // end switch
} //end for
if (success_count == childrenCount())
{
resetChildren();
// Skip if ALL the nodes have been skipped
return status() == (NodeStatus::RUNNING) ? NodeStatus::SUCCESS : NodeStatus::SKIPPED;
}
throw LogicError("ReactiveSequence is not supposed to reach this point");

it seems that this happens because if a children is SKIPPED the success_count is not increased, neither the method returns, ending in the throw. Am I right?

I can provide simple example if necessary to replicate this

@facontidavide
Copy link
Collaborator

yes, a simple example would be really great. I will fix this as soon as I receive it

@torydebra
Copy link
Author

Here you are:
image

#include "behaviortree_cpp/bt_factory.h"

using namespace BT;

// clang-format off
static const char* xml_text = R"(

<root BTCPP_format="4">
  <BehaviorTree ID="Untitled">
    <ReactiveSequence>
      <AlwaysSuccess _skipIf="flag"/>
    </ReactiveSequence>
  </BehaviorTree>
</root>

 )";

// clang-format on

int main()
{
  BehaviorTreeFactory factory;
  
  auto root_blackboard = BT::Blackboard::create();
  root_blackboard->set<bool>("flag", true);
  
  auto tree = factory.createTreeFromText(xml_text, root_blackboard);    
    
  tree.tickWhileRunning();
  
  return 0;
}

@facontidavide
Copy link
Collaborator

Fixed. Thank for reporting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants