Skip to content
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

Add functionality to clear registered behavior trees #439

Conversation

schornakj
Copy link
Contributor

@schornakj schornakj commented Sep 30, 2022

Add functions to BehaviorTreeFactory, the base Parser class, and XMLParsing to clear the parser's internal list of registered behavior trees, plus supporting unit tests.

This is needed for cases where the factory is loading user-defined behavior trees during runtime, as opposed to just loading them once at startup, since if the user deletes or edits the behavior tree definitions the factory needs to be able to reload them from scratch.

Based on work by @jliukkonen.

@facontidavide
Copy link
Collaborator

I am not sure that you really need this.

If you want to clean an entire Parser or factory, why not:

// first creation
BehaviorTreeFactory factory;
// clean up
factory = BehaviorTreeFactory{};

The effect should be exactly the same;

@schornakj
Copy link
Contributor Author

schornakj commented Oct 3, 2022

I am not sure that you really need this.

If you want to clean an entire Parser or factory, why not:

// first creation
BehaviorTreeFactory factory;
// clean up
factory = BehaviorTreeFactory{};

The effect should be exactly the same;

Deleting and recreating the whole BehaviorTreeFactory has the additional effect of de-registering all the node builder functions which have been registered up to that point. I think it's beneficial to allow clearing and reloading the registered behavior trees without requiring that custom builders be reloaded. Depending on the implementation of the class owning the BehaviorTreeFactory, there could be overhead related to registering the custom builders such as loading plugins from pluginlib which would be undesirable to repeat unnecessarily.

Behavior tree XML is simple to implement and load on the fly while a particular instance of the BehaviorTreeFactory remains running. In contrast, adding a new behavior tree node type requires modifying C++ code and either changing the implementation of the class that contains the BehaviorTreeFactory or registering a new plugin. I think it'll be much more common for someone to want to do runtime-loading of a new behavior tree XML definition vs. a new node type -- the first case is way easier to enable using tools already provided though BT.Cpp anyway.

@facontidavide facontidavide merged commit 6429868 into BehaviorTree:master Oct 5, 2022
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

Successfully merging this pull request may close these issues.

None yet

3 participants