An organizer for switching between multiple different plugins of the same type. More...
#include <plugin_mux.h>
Public Member Functions | |
void | addPlugin (const std::string &plugin_name, const std::string &plugin_class_name) |
Create an instance of the given plugin_class_name and save it with the given plugin_name. | |
T & | getCurrentPlugin () |
Get the Current Plugin. | |
std::string | getCurrentPluginName () const |
Get the Current Plugin Name. | |
T & | getPlugin (const std::string &name) |
Get the Specified Plugin. | |
std::vector< std::string > | getPluginNames () const |
Get the current list of plugin names. | |
bool | hasPlugin (const std::string &name) const |
Check to see if a plugin exists. | |
PluginMux (const std::string &plugin_package, const std::string &plugin_class, const std::string ¶meter_name, const std::string &default_value, const std::string &ros_name="current_plugin", const std::string &switch_service_name="switch_plugin") | |
Main Constructor - Loads plugin(s) and sets up ROS interfaces. | |
void | setSwitchCallback (SwitchCallback switch_callback) |
Set the callback fired when the plugin switches. | |
bool | usePlugin (const std::string &name) |
C++ Interface for switching to a given plugin. | |
Protected Member Functions | |
bool | switchPluginService (nav_2d_msgs::SwitchPlugin::Request &req, nav_2d_msgs::SwitchPlugin::Response &resp) |
ROS Interface for Switching Plugins. | |
Protected Attributes | |
std::string | current_plugin_ |
ros::Publisher | current_plugin_pub_ |
pluginlib::ClassLoader< T > | plugin_loader_ |
std::map< std::string, boost::shared_ptr< T > > | plugins_ |
ros::NodeHandle | private_nh_ |
std::string | ros_name_ |
SwitchCallback | switch_callback_ |
ros::ServiceServer | switch_plugin_srv_ |
An organizer for switching between multiple different plugins of the same type.
The different plugins are specified using a list of strings on the parameter server, each of which is a namespace. The specific type and additional parameters for each plugin are specified on the parameter server in that namespace. All the plugins are loaded initially, but only one is the "current" plugin at any particular time, which is published on a latched topic AND stored on the ROS parameter server. You can switch which plugin is current either through a C++ or ROS interface.
Definition at line 59 of file plugin_mux.h.
nav_2d_utils::PluginMux< T >::PluginMux | ( | const std::string & | plugin_package, |
const std::string & | plugin_class, | ||
const std::string & | parameter_name, | ||
const std::string & | default_value, | ||
const std::string & | ros_name = "current_plugin" , |
||
const std::string & | switch_service_name = "switch_plugin" |
||
) |
Main Constructor - Loads plugin(s) and sets up ROS interfaces.
plugin_package | The package of the plugin type |
plugin_class | The class name for the plugin type |
parameter_name | Name of parameter for the namespaces. |
default_value | If class name is not specified, which plugin should be loaded |
ros_name | ROS name for setting up topic and parameter |
switch_service_name | ROS name for setting up the ROS service |
Definition at line 221 of file plugin_mux.h.
void nav_2d_utils::PluginMux< T >::addPlugin | ( | const std::string & | plugin_name, |
const std::string & | plugin_class_name | ||
) |
Create an instance of the given plugin_class_name and save it with the given plugin_name.
plugin_name | Namespace for the new plugin |
plugin_class_name | Class type name for the new plugin |
Definition at line 258 of file plugin_mux.h.
T& nav_2d_utils::PluginMux< T >::getCurrentPlugin | ( | ) | [inline] |
Get the Current Plugin.
Definition at line 146 of file plugin_mux.h.
std::string nav_2d_utils::PluginMux< T >::getCurrentPluginName | ( | ) | const [inline] |
Get the Current Plugin Name.
Definition at line 115 of file plugin_mux.h.
T& nav_2d_utils::PluginMux< T >::getPlugin | ( | const std::string & | name | ) | [inline] |
Get the Specified Plugin.
name | Name of plugin to get |
Definition at line 135 of file plugin_mux.h.
std::vector<std::string> nav_2d_utils::PluginMux< T >::getPluginNames | ( | ) | const [inline] |
Get the current list of plugin names.
Definition at line 154 of file plugin_mux.h.
bool nav_2d_utils::PluginMux< T >::hasPlugin | ( | const std::string & | name | ) | const [inline] |
Check to see if a plugin exists.
name | Namespace to set current plugin to |
Definition at line 125 of file plugin_mux.h.
void nav_2d_utils::PluginMux< T >::setSwitchCallback | ( | SwitchCallback | switch_callback | ) | [inline] |
Set the callback fired when the plugin switches.
In addition to switching which plugin is being used via directly calling `usePlugin` a switch can also be triggered externally via ROS service. In such a case, other classes may want to know when this happens. This is accomplished using the SwitchCallback, which will be called regardless of how the plugin is switched.
Definition at line 180 of file plugin_mux.h.
bool nav_2d_utils::PluginMux< T >::switchPluginService | ( | nav_2d_msgs::SwitchPlugin::Request & | req, |
nav_2d_msgs::SwitchPlugin::Response & | resp | ||
) | [inline, protected] |
ROS Interface for Switching Plugins.
Definition at line 186 of file plugin_mux.h.
bool nav_2d_utils::PluginMux< T >::usePlugin | ( | const std::string & | name | ) | [inline] |
C++ Interface for switching to a given plugin.
name | Namespace to set current plugin to |
Definition at line 89 of file plugin_mux.h.
std::string nav_2d_utils::PluginMux< T >::current_plugin_ [protected] |
Definition at line 205 of file plugin_mux.h.
ros::Publisher nav_2d_utils::PluginMux< T >::current_plugin_pub_ [protected] |
Definition at line 209 of file plugin_mux.h.
pluginlib::ClassLoader<T> nav_2d_utils::PluginMux< T >::plugin_loader_ [protected] |
Definition at line 203 of file plugin_mux.h.
std::map<std::string, boost::shared_ptr<T> > nav_2d_utils::PluginMux< T >::plugins_ [protected] |
Definition at line 204 of file plugin_mux.h.
ros::NodeHandle nav_2d_utils::PluginMux< T >::private_nh_ [protected] |
Definition at line 210 of file plugin_mux.h.
std::string nav_2d_utils::PluginMux< T >::ros_name_ [protected] |
Definition at line 211 of file plugin_mux.h.
SwitchCallback nav_2d_utils::PluginMux< T >::switch_callback_ [protected] |
Definition at line 214 of file plugin_mux.h.
ros::ServiceServer nav_2d_utils::PluginMux< T >::switch_plugin_srv_ [protected] |
Definition at line 208 of file plugin_mux.h.