Plugin Issues
I am having an issue getting a plugin I created to load. I am successfully building the project, and the node I created is working properly because it outputs a message I coded it to output, but at startup it cannot load the plugin I created. the error message I keeping getting is "[ERROR] [1482250954.915417403]: Image ROI plugin failed to load for some reason. Error: According to the loaded plugin descriptions the class surf_matching_plugins::image_roi with base class type surf_matching_plugins_base::surf_matching_plugins_base_class does not exist. Declared types are surf_matching_plugins/image_roi"
Below is some snippets of code
My CMakelist.txt:
include_directories(include ${catkin_INCLUDE_DIRS})
add_library(surf_matching_plugins src/image_roi.cpp)
target_link_libraries(surf_matching_plugins ${catkin_LIBRARIES})
add_executable(image_roi_node src/image_roi_node_main.cpp)
target_link_libraries(image_roi_node ${catkin_LIBRARIES})
package.xml (tag format omitted):
<export>
<surf_matching plugin="${prefix}/surf_matching_plugins.xml" />
</export>
surf_matching_plugins.xml (confirmed that rospack can find it):
<library path="lib/libsurf_matching_plugins">
<class name="surf_matching_plugins/image_roi" type="surf_matching_plugins::image_roi"
base_class_type="surf_matching_plugins_base::surf_matching_plugins_base_class">
<description>Image ROI plugin.</description>
</class>
</library>
surf_matching_plugins_base.h:
namespace surf_matching_plugins_base {
class surf_matching_plugins_base_class {
public:
surf_matching_plugins_base_class();
protected:
private:
};
};
image_roi.h:
#include
</home/ikenna/Desktop/SURF_PIPELINE/catkin_ws/src/surf_matching/include/surf_matching_plugins_base_class.h>
namespace surf_matching_plugins {
class image_roi : public surf_matching_plugins_base::surf_matching_plugins_base_class {
public:
image_roi();
protected:
private:
};
};
image_roi.cpp:
#include <pluginlib/class_list_macros.h>
#include
</home/ikenna/Desktop/SURF_PIPELINE/catkin_ws/src/surf_matching/include/surf_matching_plugins_base_class.h>
#include </home/ikenna/Desktop/SURF_PIPELINE/catkin_ws/src/surf_matching/include/image_roi.h>
surf_matching_plugins::image_roi::image_roi(){
}
PLUGINLIB_EXPORT_CLASS(surf_matching_plugins::image_roi, surf_matching_plugins_base::surf_matching_plugins_base_class)
image_roi_node_main.cpp:
#include <boost/shared_ptr.hpp>
#include "ros/ros.h"
#include "std_msgs/String.h"
#include <pluginlib/class_loader.h>
#include </home/ikenna/Desktop/SURF_PIPELINE/catkin_ws/src/surf_matching/include/surf_matching_plugins_base_class.h.h>
int main(int argc, char** argv) {
// Initialize ROS first
ros::init(argc, argv, "image_roi_node");
pluginlib::ClassLoader<surf_matching_plugins_base::surf_matching_plugins_base_class> poly_loader("surf_matching", "surf_matching_plugins_base::surf_matching_plugins_base_class");
try {
boost::shared_ptr<surf_matching_plugins_base::surf_matching_plugins_base_class> image_roi_node = poly_loader.createInstance("surf_matching_plugins::image_roi");
ROS_INFO("Image ROI Node made\n");
} catch(pluginlib::PluginlibException& ex) {
ROS_ERROR("Image ROI plugin failed to load for some reason. Error: %s", ex.what());
}
ros::NodeHandle nodeHandler;
ros::Publisher image_roi_pub = nodeHandler.advertise<std_msgs::String>("image_roi", 1000);
ros::Rate loop_rate(10);
int count;
while (ros::ok()) {
std_msgs::String msg;
std::stringstream ss;
ss << " Here is the ROI\n " << count;
msg.data = ss.str();
ROS_INFO("Sent the ROI\n");
image_roi_pub.publish(msg);
ros::spinOnce();
loop_rate.sleep();
++count;
}
return 0;
}