Skip to content

Problem with BehaviorTreeEngine reset and halt #1600

@facontidavide

Description

@facontidavide

This issue is related to the ongoing discussion in #1439

I noticed that the logic of the methods resetTree
and haltAllActions is problematic.

A halted node must set the status to IDLE and an idled node must always call halt() first to do a correct cleanup of RUNNING asynchronous nodes.

A work around, for the time being, would be to have a single method like this:

    static void haltTree(BT::TreeNode * root_node)
    {
        // the halt should propagate to all the node if the nodes
        // have been implemented correctly
        root_node->halt();
        root_node->setStatus(NodeStatus::IDLE);

        //but, just in case.... 
        auto visitor = [](BT::TreeNode * node) {
            node->halt();
            node->setStatus(BT::NodeStatus::IDLE);
        };
        BT::applyRecursiveVisitor(root_node, visitor);
    }

In practice, this same problem might affect many users, therefore I made a breaking change in my API:
BehaviorTree/BehaviorTree.CPP@4f30e3a

I know people will hate me, but it is the only way to forbid users from repeating this same error.

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions