Skip to content

_skipIf precondition does not work with SubTree #507

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
alsora opened this issue Feb 16, 2023 · 2 comments
Closed

_skipIf precondition does not work with SubTree #507

alsora opened this issue Feb 16, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@alsora
Copy link
Contributor

alsora commented Feb 16, 2023

Hi, I'm using BehaviorTree.cpp version 4.0.1

I can successfully use the _skipIf precondition to avoid ticking some "standard nodes", but it seems to be ignored by the SubTrees.
I suspect that the reason has to do with the fact that subtrees forward their arguments to the children nodes for remapping

See example

class DoSomething : public BT::SyncActionNode
{
public:
  DoSomething(const std::string& name, const BT::NodeConfig& config)
    : BT::SyncActionNode(name, config)
  { }

  static BT::PortsList providedPorts()
  {
    return {  };
  }

  BT::NodeStatus tick() override
  {
    std::cout << "Hello world "<< std::endl;
    return BT::NodeStatus::SUCCESS;
  }
};

int main()
{
    auto my_factory = std::make_unique<BT::BehaviorTreeFactory>();
    my_factory->registerNodeType<CheckFloat>("CheckFloat");

    std::stringstream bt_tree_text;
    bt_tree_text << R"(
    <root BTCPP_format="4">
    <BehaviorTree ID="MySubTree">
    <Sequence>
        <Action ID="DoSomething"/>
    </Sequence>
    </BehaviorTree>
    <BehaviorTree ID="MainTree">
    <Sequence>
        <Script code=" data:=true "/>
        <SubTree ID="MySubTree" _skipIf="data"/>
    </Sequence>
    </BehaviorTree>
    </root>)";


    my_factory->registerBehaviorTreeFromText(bt_tree_text.str());
    auto tree = my_factory->createTree("MainTree");

    tree.tickWhileRunning();
    
    return 0;
}
@facontidavide
Copy link
Collaborator

thanks a lot @alsora , I shall look at this ASAP

@facontidavide facontidavide self-assigned this Feb 16, 2023
@facontidavide facontidavide added the bug Something isn't working label Feb 16, 2023
facontidavide added a commit that referenced this issue Feb 17, 2023
@facontidavide
Copy link
Collaborator

facontidavide commented Feb 17, 2023

Fixed and unit test added.
Wow, that was a big problem, thanks for reporting

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants