From 66d3aa622e592605ab2410a035394efdb7601ba3 Mon Sep 17 00:00:00 2001 From: marqrazz Date: Thu, 9 May 2024 17:36:34 -0600 Subject: [PATCH] Register multiple nodes with single plugin --- .../include/behaviortree_ros2/plugins.hpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/behaviortree_ros2/include/behaviortree_ros2/plugins.hpp b/behaviortree_ros2/include/behaviortree_ros2/plugins.hpp index 116fd2c..e3b9108 100644 --- a/behaviortree_ros2/include/behaviortree_ros2/plugins.hpp +++ b/behaviortree_ros2/include/behaviortree_ros2/plugins.hpp @@ -25,6 +25,25 @@ namespace BT constexpr const char* ROS_PLUGIN_SYMBOL = "BT_RegisterRosNodeFromPlugin"; } +/* Use this macro to automatically register one or more custom Nodes +* into a factory that require access to the BT::RosNodeParams. +* For instance: +* +* BT_REGISTER_ROS_NODES(factory, params) +* { +* factory.registerNodeType("SpecialNode", params); +* } +* +* IMPORTANT: this function MUST be declared in a cpp file, NOT a header file. +* You must add the definition [BT_PLUGIN_EXPORT] in CMakeLists.txt using: +* +* target_compile_definitions(my_plugin_target PRIVATE BT_PLUGIN_EXPORT ) +*/ + +#define BT_REGISTER_ROS_NODES(factory, params) \ + BTCPP_EXPORT void BT_RegisterRosNodeFromPlugin(BT::BehaviorTreeFactory& factory, \ + const BT::RosNodeParams& params) + // Use this macro to generate a plugin for: // // - BT::RosActionNode