ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Plugin Issues

asked 2016-12-20 10:48:35 -0500

IkennaOkafor gravatar image

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;
    }
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2016-12-20 17:00:52 -0500

IkennaOkafor gravatar image

updated 2016-12-20 17:01:33 -0500

The issue was I did not make my base class functions virtual, also my constructor for the image_roi class should have been image_roi(void). I cant accept my own answer because Im new but this is it for future reference.

edit flag offensive delete link more
0

answered 2016-12-20 14:22:35 -0500

rbbg gravatar image

The error tells you that the loader is not aware of surf_matching_plugins::image_roi plugin but does know a surf_matching_plugins/image_roi plugin. It seems like you are trying to load the plugin by the type instead of the name (as specified in your surf_matching_plugins.xml). If you change

poly_loader.createInstance("surf_matching_plugins::image_roi");

to

poly_loader.createInstance("surf_matching_plugins/image_roi");

The loader should be able to find the right plugin.

Good luck

edit flag offensive delete link more

Comments

When I do that and run it i get an error saying "/home/ikenna/Desktop/SURF_PIPELINE/catkin_ws/devel/lib/surf_matching/image_roi_node: symbol lookup error: /home/ikenna/Desktop/SURF_PIPELINE/catkin_ws/devel/lib//libsurf_matching_plugins.so: undefined symbol: _ZN21surf_matching_plugins9image_roiC1Ev"

IkennaOkafor gravatar image IkennaOkafor  ( 2016-12-20 15:31:41 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2016-12-20 10:48:35 -0500

Seen: 322 times

Last updated: Dec 20 '16