9 #ifndef MC_RTC_BUILD_STATIC
11 # include <mc_rtc/version.h>
22 # define CONTROLLER_CHECK_VERSION(NAME) \
23 if(mc_rtc::MC_RTC_VERSION != mc_rtc::version()) \
25 mc_rtc::log::error("{} was compiled with {} but mc_rtc is currently at version {}, you might experience subtle " \
26 "issues and should recompile your code", \
27 NAME, mc_rtc::MC_RTC_VERSION, mc_rtc::version()); \
31 # define CONTROLLER_CONSTRUCTOR(NAME, TYPE) \
34 CONTROLLER_MODULE_API void MC_RTC_CONTROLLER(std::vector<std::string> & names) \
36 CONTROLLER_CHECK_VERSION(NAME) \
39 CONTROLLER_MODULE_API void destroy(mc_control::MCController * ptr) \
41 CONTROLLER_MODULE_API unsigned int create_args_required() \
43 CONTROLLER_MODULE_API mc_control::MCController * create(const std::string &, \
44 const mc_rbdyn::RobotModulePtr & robot, \
46 const mc_control::Configuration & conf) \
47 { return new TYPE(robot, dt, conf); } \
51 # define MULTI_CONTROLLERS_CONSTRUCTOR(NAME0, NEWCTL0, NAME1, NEWCTL1) \
54 CONTROLLER_MODULE_API void MC_RTC_CONTROLLER(std::vector<std::string> & names) \
56 CONTROLLER_CHECK_VERSION(NAME0) \
57 names = {NAME0, NAME1}; \
60 CONTROLLER_MODULE_API void destroy(mc_control::MCController * ptr) \
62 CONTROLLER_MODULE_API unsigned int create_args_required() \
64 CONTROLLER_MODULE_API mc_control::MCController * create( \
65 const std::string & name, \
66 const mc_rbdyn::RobotModulePtr & rm, \
68 [[maybe_unused]] const mc_control::Configuration & config) \
70 if(name == NAME0) { return new NEWCTL0; } \
76 # define SIMPLE_CONTROLLER_CONSTRUCTOR(NAME, TYPE) \
79 CONTROLLER_MODULE_API void MC_RTC_CONTROLLER(std::vector<std::string> & names) \
81 CONTROLLER_CHECK_VERSION(NAME) \
84 CONTROLLER_MODULE_API void destroy(mc_control::MCController * ptr) \
86 CONTROLLER_MODULE_API unsigned int create_args_required() \
88 CONTROLLER_MODULE_API mc_control::MCController * create(const std::string &, \
89 const mc_rbdyn::RobotModulePtr & robot, \
91 const mc_control::Configuration &) \
92 { return new TYPE(robot, dt); } \
99 # define CONTROLLER_CONSTRUCTOR(NAME, TYPE) \
102 static auto registered = []() \
104 using fn_t = std::function<TYPE *(const std::shared_ptr<mc_rbdyn::RobotModule> &, const double &, \
105 const mc_control::Configuration &)>; \
106 mc_control::ControllerLoader::loader().register_object( \
107 NAME, fn_t([](const std::shared_ptr<mc_rbdyn::RobotModule> & robot, const double & dt, \
108 const mc_control::Configuration & conf) { return new TYPE(robot, dt, conf); })); \
113 # define MULTI_CONTROLLERS_CONSTRUCTOR(NAME0, NEWCTL0, NAME1, NEWCTL1) \
116 static auto registered = []() \
118 using TYPE0 = decltype(NEWCTL0); \
119 using TYPE1 = decltype(NEWCTL1); \
120 using fn0_t = std::function<TYPE0 *(const std::shared_ptr<mc_rbdyn::RobotModule> &, const double &, \
121 const mc_control::Configuration &)>; \
122 mc_control::ControllerLoader::loader().register_object( \
123 NAME0, fn_t([](const std::shared_ptr<mc_rbdyn::RobotModule> & robot, const double & dt, \
124 const mc_control::Configuration & conf) { return new NEWCTL0; })); \
125 using fn1_t = std::function<TYPE1 *(const std::shared_ptr<mc_rbdyn::RobotModule> &, const double &, \
126 const mc_control::Configuration &)>; \
127 mc_control::ControllerLoader::loader().register_object( \
128 NAME1, fn_t([](const std::shared_ptr<mc_rbdyn::RobotModule> & robot, const double & dt, \
129 const mc_control::Configuration & conf) { return new NEWCTL1; })); \
134 # define SIMPLE_CONTROLLER_CONSTRUCTOR(NAME, TYPE) \
137 static auto registered = []() \
139 using fn_t = std::function<TYPE *(const std::shared_ptr<mc_rbdyn::RobotModule> &, const double &, \
140 const mc_control::Configuration &)>; \
141 mc_control::ControllerLoader::loader().register_object( \
142 NAME, fn_t([](const std::shared_ptr<mc_rbdyn::RobotModule> & robot, const double & dt, \
143 const mc_control::Configuration &) { return new TYPE(robot, dt); })); \