mc_controller.h File Reference
#include <mc_control/MCController.h>
#include <mc_rtc/version.h>
Include dependency graph for mc_controller.h:

Go to the source code of this file.

Macros

#define CONTROLLER_CHECK_VERSION(NAME)
 
#define CONTROLLER_CONSTRUCTOR(NAME, TYPE)
 
#define MULTI_CONTROLLERS_CONSTRUCTOR(NAME0, NEWCTL0, NAME1, NEWCTL1)
 
#define SIMPLE_CONTROLLER_CONSTRUCTOR(NAME, TYPE)
 

Macro Definition Documentation

◆ CONTROLLER_CHECK_VERSION

#define CONTROLLER_CHECK_VERSION (   NAME)
Value:
if(mc_rtc::MC_RTC_VERSION != mc_rtc::version()) \
{ \
mc_rtc::log::error("{} was compiled with {} but mc_rtc is currently at version {}, you might experience subtle " \
"issues and should recompile your code", \
NAME, mc_rtc::MC_RTC_VERSION, mc_rtc::version()); \
}

Set of macros to assist with the writing of an MCController A simple compile-time versus run-time version checking macro

If you are not relying on CONTROLLER_CONSTRUCTOR or SIMPLE_CONTROLLER_CONSTRUCTOR you should use this in your MC_RTC_CONTROLLER implementation

◆ CONTROLLER_CONSTRUCTOR

#define CONTROLLER_CONSTRUCTOR (   NAME,
  TYPE 
)
Value:
extern "C" \
{ \
CONTROLLER_MODULE_API void MC_RTC_CONTROLLER(std::vector<std::string> & names) \
{ \
CONTROLLER_CHECK_VERSION(NAME) \
names = {NAME}; \
} \
CONTROLLER_MODULE_API void destroy(mc_control::MCController * ptr) \
{ \
delete ptr; \
} \
CONTROLLER_MODULE_API unsigned int create_args_required() \
{ \
return 4; \
} \
CONTROLLER_MODULE_API mc_control::MCController * create(const std::string &, \
const mc_rbdyn::RobotModulePtr & robot, \
const double & dt, \
const mc_control::Configuration & conf) \
{ \
return new TYPE(robot, dt, conf); \
} \
}

Provides a handle to construct the controller with Json config

◆ MULTI_CONTROLLERS_CONSTRUCTOR

#define MULTI_CONTROLLERS_CONSTRUCTOR (   NAME0,
  NEWCTL0,
  NAME1,
  NEWCTL1 
)
Value:
extern "C" \
{ \
CONTROLLER_MODULE_API void MC_RTC_CONTROLLER(std::vector<std::string> & names) \
{ \
CONTROLLER_CHECK_VERSION(NAME0) \
names = {NAME0, NAME1}; \
} \
\
CONTROLLER_MODULE_API void destroy(mc_control::MCController * ptr) \
{ \
delete ptr; \
} \
CONTROLLER_MODULE_API unsigned int create_args_required() \
{ \
return 4; \
} \
CONTROLLER_MODULE_API mc_control::MCController * create( \
const std::string & name, \
const double & dt, \
[[maybe_unused]] const mc_control::Configuration & config) \
{ \
if(name == NAME0) { return new NEWCTL0; } \
return new NEWCTL1; \
} \
}

Provides all functions except create

◆ SIMPLE_CONTROLLER_CONSTRUCTOR

#define SIMPLE_CONTROLLER_CONSTRUCTOR (   NAME,
  TYPE 
)
Value:
extern "C" \
{ \
CONTROLLER_MODULE_API void MC_RTC_CONTROLLER(std::vector<std::string> & names) \
{ \
CONTROLLER_CHECK_VERSION(NAME) \
names = {NAME}; \
} \
CONTROLLER_MODULE_API void destroy(mc_control::MCController * ptr) \
{ \
delete ptr; \
} \
CONTROLLER_MODULE_API unsigned int create_args_required() \
{ \
return 4; \
} \
CONTROLLER_MODULE_API mc_control::MCController * create(const std::string &, \
const mc_rbdyn::RobotModulePtr & robot, \
const double & dt, \
{ \
return new TYPE(robot, dt); \
} \
}

Provides a handle to construct a generic controller

mc_rtc::Configuration
Simplify access to values hold within a JSON file.
Definition: Configuration.h:165
mc_rtc::log::error
void error(Args &&... args)
Definition: logging.h:63
mc_rbdyn::RobotModulePtr
std::shared_ptr< RobotModule > RobotModulePtr
Definition: RobotModule.h:629
mc_control::MCController
MCController is the base class to implement all controllers. It assumes that at least two robots are ...
Definition: MCController.h:98