2 #include <pluginlib/class_loader.h> 
    3 #include "geometry_msgs/PoseWithCovarianceStamped.h" 
    5 #include <dynamic_reconfigure/server.h> 
    6 #include <plugin_demo_main/plugin_demoConfig.h> 
    8 boost::shared_ptr<plugin_demo_interface_namespace::PathPlanner> plugin_node;
 
    9 std::string plugin_name;
 
   10 bool change_plugin, use_shared_pointer;
 
   11 ros::Publisher setStartPub;
 
   12 double delta_x, delta_y, delta_theta;
 
   14 void getStartCallback(
const geometry_msgs::PoseWithCovarianceStamped event)
 
   16     if (use_shared_pointer) 
 
   18         geometry_msgs::Pose2DPtr msg(
new geometry_msgs::Pose2D);
 
   19         msg->x = 
event.pose.pose.position.x;
 
   20         msg->y = 
event.pose.pose.position.y;
 
   21         msg->theta = plugin_node->getYawFromQuat(event.pose.pose.orientation);
 
   22         setStartPub.publish(msg);
 
   25         msg->theta += delta_theta;
 
   27         geometry_msgs::Pose2D msg;
 
   28         msg.x = 
event.pose.pose.position.x;
 
   29         msg.y = 
event.pose.pose.position.y;
 
   30         msg.theta = plugin_node->getYawFromQuat(event.pose.pose.orientation);
 
   31         setStartPub.publish(msg);
 
   34         msg.theta += delta_theta;
 
   38 void reconfigureCallback(plugin_demo_main::plugin_demoConfig &config, uint32_t level)
 
   40     use_shared_pointer = config.use_shared_pointer;
 
   41     delta_x = config.delta_x;
 
   42     delta_y = config.delta_y;
 
   43     delta_theta = config.delta_theta;
 
   45     if (config.plugin != plugin_name)
 
   47         plugin_name = config.plugin;
 
   52 int loadPlugin(pluginlib::ClassLoader<plugin_demo_interface_namespace::PathPlanner> *plug_in_loader, ros::NodeHandle *roshandle, std::string plugin_name)
 
   54     ROS_INFO(
"[main] starting plugin \"%s\"", plugin_name.c_str());
 
   58         plugin_node = plug_in_loader->createInstance(plugin_name.c_str());
 
   59         plugin_node->initialize(*roshandle);        
 
   60     } 
catch(pluginlib::PluginlibException& ex) {
 
   61         ROS_FATAL(
"[main] failed to load. Error: \"%s\"\nGoodbye.", ex.what());
 
   64     ROS_INFO(
"[main] module loaded");
 
   68 int main(
int argc, 
char **argv)
 
   70     ros::init(argc, argv, 
"plugin_demo_path_planner");
 
   71     ros::NodeHandle roshandle;
 
   73     dynamic_reconfigure::Server<plugin_demo_main::plugin_demoConfig> reconfServer;
 
   74     dynamic_reconfigure::Server<plugin_demo_main::plugin_demoConfig>::CallbackType f;
 
   75     f = boost::bind(&reconfigureCallback, _1, _2);
 
   76     reconfServer.setCallback(f);
 
   78     ros::Subscriber newStartSub;
 
   79     newStartSub = roshandle.subscribe(
"get_start", 10, &getStartCallback);
 
   80     setStartPub = roshandle.advertise<geometry_msgs::Pose2D>(
"set_start", 10);
 
   81     use_shared_pointer = 
false;
 
   84     ros::param::param<std::string>(
"~plugin", plugin_name, 
"plugin_demo_plugins_namespace::Direct");
 
   85     change_plugin = 
false;
 
   87     pluginlib::ClassLoader<plugin_demo_interface_namespace::PathPlanner> plug_in_loader(
"plugin_demo_interface", 
"plugin_demo_interface_namespace::PathPlanner");
 
   89     loadPlugin(&plug_in_loader, &roshandle, plugin_name);
 
   90     plugin_node->initialize(roshandle);
 
   97             geometry_msgs::Pose2D start, target;
 
   98             plugin_node->getPoints(&start, &target);
 
   99             loadPlugin(&plug_in_loader, &roshandle, plugin_name);
 
  100             plugin_node->setPoints(&start, &target);
 
  101             change_plugin = 
false;
 
Contain the Interface  class.