Groot
Groot copied to clipboard
Support for BehaviorTree.CPP plugins
Hi, I started working with Groot recently, but I don't really understand how the workflow with BehaviorTree.CPP works. Let's say I deploy a BehaviorTree.CPP compliant package. This package generates a plugin on compilation that offers some functionality by means of several leaves nodes (for example to control and monitor a given system). I would like other users (they may not be too tech-savy) to compile this package, get access to the nodes that are defined in this plugin and build a behavior tree using just the GUI. As far as I know the only way to do this right now is to somehow generate a XML tree file that contains the definition of the nodes using this plugin (on runtime?). This same XML file can be later loaded in Groot, and the custom made nodes would be available to select and use from the nodes model list. Is this correct?
I have been playing around a bit and I managed to import plugins and load whatever nodes it may define into the model list. The load function would look more or less like this (in mainwindow.cpp
):
void MainWindow::loadFromPlugin(const QString& plugin_path)
{
BT::BehaviorTreeFactory factory;
factory.registerFromPlugin(plugin_path.toStdString());
const auto& manifests = factory.manifests();
for(const auto& manifest : manifests)
{
auto registration_id = QString::fromStdString(manifest.registration_ID);
auto node_type = getNodeTypeFromString(QString::fromStdString(BT::toStr(manifest.type)));
using ModelParam = TreeNodeModel::Param;
using NodeParameter = BT::NodeParameters::value_type;
std::vector<ModelParam> node_parameters;
std::transform(manifest.required_parameters.cbegin(), manifest.required_parameters.cend(), std::back_inserter(node_parameters),
[] (const NodeParameter& parameter) { return ModelParam{ QString::fromStdString(parameter.first), QString::fromStdString(parameter.second) }; });
onAddToModelRegistry(TreeNodeModel(registration_id, node_type, node_parameters));
}
}
Would a functionality like this be acceptable? For this to work Groot should be linked against the BehaviorTree.CPP library of course.
Not only a fully agree with you, but this upgrade is already in my TODO list.
To "do it right" and avoid code duplication, I should actually include BehaviorTre.CPP as a dependency of Groot. But this requires some work. I will probably do that the first week of December.
Cheers and MANY THANKS for helping me with your suggestions and issue reports.
I see, looking forward to it. Thank you!
+1 For this feature.
I can also give some help testing it together with the ver_3
branch of BT.
My plan is to update Groot to ver_3 the first two weeks of February.
Has any progress been made on this front? I've been equally confused by the workflow and the relation between custom nodes created with BehaviorTree.CPP and the GUI editor.
+1 on raising my hand that this would be great for minimizing the hassle of creating additional xmls describing what the plugin already includes.. :slightly_smiling_face: