mc_rtc::Configuration
general purpose configurationIn mc_rtc, every interface uses the mc_control::MCGlobalController
class to initialize and run the controllers in the framework. In particular, they will run the mc_control::MCGlobalController::run()
function on every iteration.
The plugin system allows one to write a component that will run at the start and/or end of this run function.
These plugins can be used for a variety of purpose:
To write a plugin you should write a class that derives from the mc_control::GlobalPlugin
class. Then you must implement the following functions:
mc_control::GlobalPlugin::init()
is called by mc_rtc when mc_control::MCGlobalController::init()
is calledmc_control::GlobalPlugin::reset()
is called by mc_rtc when the controller is changedmc_control::GlobalPlugin::before()
is called by mc_rtc at the beginning of the run functionmc_control::GlobalPlugin::after()
is called by mc_rtc at the end of the run functionFinally, your class must be exported in a shared library that can be loaded by mc_rtc. The simplest way to achieve this is to use the EXPORT_MC_RTC_PLUGIN
macro in mc_rtc, similar to its counterpart for controllers, states and robot modules.
Optionally, you can override the mc_cotrol::GlobalPlugin::configuration() method. This lets you inform mc_rtc that your plugin does not to run before or after the run loop or whether your plugin should run when the controller is not running.
By default, a plugin's before
and after
method is always called.
The CMake macro add_plugin
automatically creates a CMake option named AUTOLOAD_${PLUGIN}_PLUGIN
. When this option is ON
, a special file will be installed in ${MC_RTC_INSTALL_PREFIX}/lib/mc_plugins/autoload
. When this file is present, the plugin will be automatically loaded regardless of the Plugins
configuration entry.
Use the mc-rtc/new-plugin template project to get started quickly. This template provides the barebone structure for a C++ GlobalPlugin