17#include <boost/core/demangle.hpp>
21#include "auto_apms_behavior_tree_core/node/node_registration_interface.hpp"
34 class T,
typename = std::enable_if_t<std::is_base_of_v<BT::TreeNode, T>>,
35 bool requires_ros_node_params =
36 std::is_constructible_v<T, const std::string &, const BT::NodeConfig &, RosNodeContext>>
37class NodeRegistrationTemplate :
public NodeRegistrationInterface
40 NodeRegistrationTemplate() =
default;
41 virtual ~NodeRegistrationTemplate() =
default;
43 bool requiresRosNodeContext()
const override {
return requires_ros_node_params; }
45 void registerWithBehaviorTreeFactory(
46 BT::BehaviorTreeFactory & factory,
const std::string & registration_name,
47 const RosNodeContext *
const context_ptr =
nullptr)
const override
49 if constexpr (requires_ros_node_params) {
51 throw std::invalid_argument(
52 boost::core::demangle(
typeid(T).name()) +
53 " requires a valid RosNodeContext object to be passed via argument 'context_ptr'.");
55 factory.registerNodeType<T>(registration_name, *context_ptr);
57 factory.registerNodeType<T>(registration_name);
Core API for AutoAPMS's behavior tree implementation.