Public Member Functions | Protected Member Functions | Protected Attributes
nav_2d_utils::PluginMux< T > Class Template Reference

An organizer for switching between multiple different plugins of the same type. More...

#include <plugin_mux.h>

List of all members.

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.
TgetCurrentPlugin ()
 Get the Current Plugin.
std::string getCurrentPluginName () const
 Get the Current Plugin Name.
TgetPlugin (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 &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.
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< Tplugin_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_

Detailed Description

template<class T>
class nav_2d_utils::PluginMux< T >

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.


Constructor & Destructor Documentation

template<class T >
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.

Parameters:
plugin_packageThe package of the plugin type
plugin_classThe class name for the plugin type
parameter_nameName of parameter for the namespaces.
default_valueIf class name is not specified, which plugin should be loaded
ros_nameROS name for setting up topic and parameter
switch_service_nameROS name for setting up the ROS service

Definition at line 221 of file plugin_mux.h.


Member Function Documentation

template<class T >
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.

Parameters:
plugin_nameNamespace for the new plugin
plugin_class_nameClass type name for the new plugin

Definition at line 258 of file plugin_mux.h.

template<class T >
T& nav_2d_utils::PluginMux< T >::getCurrentPlugin ( ) [inline]

Get the Current Plugin.

Returns:
Reference to current plugin

Definition at line 146 of file plugin_mux.h.

template<class T >
std::string nav_2d_utils::PluginMux< T >::getCurrentPluginName ( ) const [inline]

Get the Current Plugin Name.

Returns:
Name of the current plugin

Definition at line 115 of file plugin_mux.h.

template<class T >
T& nav_2d_utils::PluginMux< T >::getPlugin ( const std::string &  name) [inline]

Get the Specified Plugin.

Parameters:
nameName of plugin to get
Returns:
Reference to specified plugin

Definition at line 135 of file plugin_mux.h.

template<class T >
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.

template<class T >
bool nav_2d_utils::PluginMux< T >::hasPlugin ( const std::string &  name) const [inline]

Check to see if a plugin exists.

Parameters:
nameNamespace to set current plugin to
Returns:
True if the plugin exists

Definition at line 125 of file plugin_mux.h.

template<class T >
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.

template<class T >
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.

template<class T >
bool nav_2d_utils::PluginMux< T >::usePlugin ( const std::string &  name) [inline]

C++ Interface for switching to a given plugin.

Parameters:
nameNamespace to set current plugin to
Returns:
true if that namespace exists and is loaded properly

Definition at line 89 of file plugin_mux.h.


Member Data Documentation

template<class T >
std::string nav_2d_utils::PluginMux< T >::current_plugin_ [protected]

Definition at line 205 of file plugin_mux.h.

template<class T >
ros::Publisher nav_2d_utils::PluginMux< T >::current_plugin_pub_ [protected]

Definition at line 209 of file plugin_mux.h.

template<class T >
pluginlib::ClassLoader<T> nav_2d_utils::PluginMux< T >::plugin_loader_ [protected]

Definition at line 203 of file plugin_mux.h.

template<class T >
std::map<std::string, boost::shared_ptr<T> > nav_2d_utils::PluginMux< T >::plugins_ [protected]

Definition at line 204 of file plugin_mux.h.

template<class T >
ros::NodeHandle nav_2d_utils::PluginMux< T >::private_nh_ [protected]

Definition at line 210 of file plugin_mux.h.

template<class T >
std::string nav_2d_utils::PluginMux< T >::ros_name_ [protected]

Definition at line 211 of file plugin_mux.h.

template<class T >
SwitchCallback nav_2d_utils::PluginMux< T >::switch_callback_ [protected]

Definition at line 214 of file plugin_mux.h.

template<class T >
ros::ServiceServer nav_2d_utils::PluginMux< T >::switch_plugin_srv_ [protected]

Definition at line 208 of file plugin_mux.h.


The documentation for this class was generated from the following file:


nav_2d_utils
Author(s):
autogenerated on Wed Jun 26 2019 20:09:36