19#include "auto_apms_behavior_tree_core/node/node_manifest.hpp"
20#include "auto_apms_behavior_tree_core/tree/tree_document.hpp"
21#include "auto_apms_util/string.hpp"
25int main(
int argc,
char ** argv)
27 if (argc < 2 || argc > 3) {
28 std::cerr <<
"create_node_model_for_manifest_resource: Wrong number of arguments!\n";
29 std::cerr <<
"Usage: create_node_model_for_manifest_resource <output_file>\n";
30 std::cerr <<
" create_node_model_for_manifest_resource <output_file> <node_manifest_resource_identity>\n";
31 std::cerr <<
"\nIf only output_file is provided, generates model for native BehaviorTree.CPP nodes.\n";
32 std::cerr <<
"If both arguments are provided, generates model for the specified node manifest resource.\n";
37 std::filesystem::path output_file;
38 std::string manifest_resource_identity;
39 bool use_native_only =
false;
46 use_native_only =
true;
53 if (output_file.extension() !=
".xml") {
54 throw std::runtime_error(
"Output file '" + output_file.string() +
"' has wrong extension. Must be '.xml'.");
58 std::filesystem::create_directories(output_file.parent_path());
63 if (use_native_only) {
74 }
catch (
const std::exception & e) {
75 std::cerr <<
"ERROR (create_node_model_for_manifest_resource): " << e.what() <<
"\n";
static NodeManifest fromResource(const NodeManifestResourceIdentity &search_identity)
Create a node manifest from an installed resource.
Document Object Model (DOM) for the behavior tree XML schema. This class offers a programmatic approa...
void writeToFile(const std::string &path) const
Write the XML of this tree document to a file.
virtual TreeDocument & registerNodes(const NodeManifest &tree_node_manifest, bool override=false)
Load behavior tree node plugins and register them with the internal behavior tree factory.
TreeDocument & addNodeModel(NodeModelMap model_map)
Add a behavior tree node model element to the document by parsing the contents of model_map.
static NodeModelMap getNodeModel(tinyxml2::XMLDocument &doc, const NodeManifest &manifest)
Convert a behavior tree node model document to the corresponding data structure.
std::string trimWhitespaces(const std::string &str)
Trim whitespaces from both ends of a string.
Powerful tooling for incorporating behavior trees for task development.