Go to the documentation of this file.
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) \
43 CONTROLLER_MODULE_API unsigned int create_args_required() \
47 CONTROLLER_MODULE_API mc_control::MCController * create(const std::string &, \
48 const mc_rbdyn::RobotModulePtr & robot, \
50 const mc_control::Configuration & conf) \
52 return new TYPE(robot, dt, conf); \
57 # define MULTI_CONTROLLERS_CONSTRUCTOR(NAME0, NEWCTL0, NAME1, NEWCTL1) \
60 CONTROLLER_MODULE_API void MC_RTC_CONTROLLER(std::vector<std::string> & names) \
62 CONTROLLER_CHECK_VERSION(NAME0) \
63 names = {NAME0, NAME1}; \
66 CONTROLLER_MODULE_API void destroy(mc_control::MCController * ptr) \
70 CONTROLLER_MODULE_API unsigned int create_args_required() \
74 CONTROLLER_MODULE_API mc_control::MCController * create( \
75 const std::string & name, \
76 const mc_rbdyn::RobotModulePtr & rm, \
78 [[maybe_unused]] const mc_control::Configuration & config) \
80 if(name == NAME0) { return new NEWCTL0; } \
86 # define SIMPLE_CONTROLLER_CONSTRUCTOR(NAME, TYPE) \
89 CONTROLLER_MODULE_API void MC_RTC_CONTROLLER(std::vector<std::string> & names) \
91 CONTROLLER_CHECK_VERSION(NAME) \
94 CONTROLLER_MODULE_API void destroy(mc_control::MCController * ptr) \
98 CONTROLLER_MODULE_API unsigned int create_args_required() \
102 CONTROLLER_MODULE_API mc_control::MCController * create(const std::string &, \
103 const mc_rbdyn::RobotModulePtr & robot, \
105 const mc_control::Configuration &) \
107 return new TYPE(robot, dt); \
115 # define CONTROLLER_CONSTRUCTOR(NAME, TYPE) \
118 static auto registered = []() \
120 using fn_t = std::function<TYPE *(const std::shared_ptr<mc_rbdyn::RobotModule> &, const double &, \
121 const mc_control::Configuration &)>; \
122 mc_control::ControllerLoader::loader().register_object( \
123 NAME, fn_t([](const std::shared_ptr<mc_rbdyn::RobotModule> & robot, const double & dt, \
124 const mc_control::Configuration & conf) { return new TYPE(robot, dt, conf); })); \
129 # define MULTI_CONTROLLERS_CONSTRUCTOR(NAME0, NEWCTL0, NAME1, NEWCTL1) \
132 static auto registered = []() \
134 using TYPE0 = decltype(NEWCTL0); \
135 using TYPE1 = decltype(NEWCTL1); \
136 using fn0_t = std::function<TYPE0 *(const std::shared_ptr<mc_rbdyn::RobotModule> &, const double &, \
137 const mc_control::Configuration &)>; \
138 mc_control::ControllerLoader::loader().register_object( \
139 NAME0, fn_t([](const std::shared_ptr<mc_rbdyn::RobotModule> & robot, const double & dt, \
140 const mc_control::Configuration & conf) { return new NEWCTL0; })); \
141 using fn1_t = std::function<TYPE1 *(const std::shared_ptr<mc_rbdyn::RobotModule> &, const double &, \
142 const mc_control::Configuration &)>; \
143 mc_control::ControllerLoader::loader().register_object( \
144 NAME1, fn_t([](const std::shared_ptr<mc_rbdyn::RobotModule> & robot, const double & dt, \
145 const mc_control::Configuration & conf) { return new NEWCTL1; })); \
150 # define SIMPLE_CONTROLLER_CONSTRUCTOR(NAME, TYPE) \
153 static auto registered = []() \
155 using fn_t = std::function<TYPE *(const std::shared_ptr<mc_rbdyn::RobotModule> &, const double &, \
156 const mc_control::Configuration &)>; \
157 mc_control::ControllerLoader::loader().register_object( \
158 NAME, fn_t([](const std::shared_ptr<mc_rbdyn::RobotModule> & robot, const double & dt, \
159 const mc_control::Configuration &) { return new TYPE(robot, dt); })); \