diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..c2bdbef --- /dev/null +++ b/.clang-format @@ -0,0 +1,3 @@ +BasedOnStyle: LLVM +IndentWidth: 4 +ColumnLimit: 140 \ No newline at end of file diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..3a52c72 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,8 @@ +root = true + +[*] +indent_size = 4 +indent_style = space +charset = utf-8 +end_of_line = lf +insert_final_newline = true diff --git a/src/btree_nodes/src/Extensions.cpp b/src/btree_nodes/src/Extensions.cpp index 7e4eb1e..730dbbd 100644 --- a/src/btree_nodes/src/Extensions.cpp +++ b/src/btree_nodes/src/Extensions.cpp @@ -50,13 +50,13 @@ namespace BT { } auto pose = std::make_shared(); - pose->orientation.w=0; - pose->orientation.x=0; - pose->orientation.y=1; - pose->orientation.z=0; - pose->position.x= convertFromString(parts[0]); - pose->position.y= convertFromString(parts[1]); - pose->position.z= convertFromString(parts[2]); + pose->orientation.w = 0; + pose->orientation.x = 0; + pose->orientation.y = 1; + pose->orientation.z = 0; + pose->position.x = convertFromString(parts[0]); + pose->position.y = convertFromString(parts[1]); + pose->position.z = convertFromString(parts[2]); std::cout << "[ generated pose from string ]" << std::endl; @@ -71,9 +71,9 @@ namespace BT { } auto point = std::make_shared(); - point->x= convertFromString(parts[0]); - point->y= convertFromString(parts[1]); - point->z= convertFromString(parts[2]); + point->x = convertFromString(parts[0]); + point->y = convertFromString(parts[1]); + point->z = convertFromString(parts[2]); return point; } @@ -86,10 +86,10 @@ namespace BT { } auto point = std::make_shared(); - point->w= convertFromString(parts[0]); - point->x= convertFromString(parts[1]); - point->y= convertFromString(parts[2]); - point->z= convertFromString(parts[3]); + point->w = convertFromString(parts[0]); + point->x = convertFromString(parts[1]); + point->y = convertFromString(parts[2]); + point->z = convertFromString(parts[3]); return point; } diff --git a/src/btree_nodes/src/Tree.cpp b/src/btree_nodes/src/Tree.cpp index c0c9073..f8d7b1e 100644 --- a/src/btree_nodes/src/Tree.cpp +++ b/src/btree_nodes/src/Tree.cpp @@ -1,5 +1,6 @@ #include "Area.h" #include +#include #include #include #include @@ -139,9 +140,17 @@ int main(int argc, char **argv) { factory.registerSimpleAction("SetCalledTo",SetCalledTo,{InputPort("state","state to set called to")}); std::cout << "Creating tree." << std::endl; - - Tree actorTree = factory.createTreeFromFile("/home/ros/workspace/src/btree_nodes/actorTree.xml",blackboard); - Tree robotTree = factory.createTreeFromFile("/home/ros/workspace/src/btree_nodes/robotTree.xml",blackboard); + + mainNode -> declare_parameter("trees",std::vector({ + "/home/ros/workspace/src/btree_nodes/actorTree.xml", + "/home/ros/workspace/src/btree_nodes/robotTree.xml" + })); + + auto treeFileNames = mainNode -> get_parameter("trees").as_string_array(); + auto trees = std::vector>(); + for(auto treeFileName : treeFileNames){ + trees.emplace_back(std::make_shared(factory.createTreeFromFile(treeFileName,blackboard))); + } auto init = std::make_shared(); init->position.x = 6.0; @@ -167,8 +176,9 @@ int main(int argc, char **argv) { while (rclcpp::ok()) { blackboardMutex.lock(); - actorTree.tickRoot(); - robotTree.tickRoot(); + for(auto tree : trees){ + tree->tickRoot(); + } blackboardMutex.unlock(); }