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

Unable to load plugins; ClassLoader error

asked 2015-11-04 20:21:32 -0500

robo_explorer gravatar image

updated 2019-07-10 01:00:51 -0500

jayess gravatar image

I have created a plugin to test some changes that I will make in the exploration algorithm later. But, I am unable to load the plugins which I created. When I run my launch file, it calls for this plugin, but I get the following error:

[ERROR] [1446688037.439927809]: Failed to load exploration plugin! Error: MultiLibraryClassLoader: Could not create object of class type NearestBasedAllocation as no factory exists for it. Make sure that the library exists and was explicitly loaded through MultiLibraryClassLoader::loadLibrary()

In my package.xml, I am using export tag to link to frontier.xml:

<export>
    <nav2d_navigator plugin="${prefix}/frontier.xml" />  
</export>

While in frontier.xml, I am giving a brief explanation about my class

<library path="libFrontierPlugins">
    <class name="NearestBasedAllocation" type="NearestBasedAllocation" base_class_type="ExplorationPlanner">
        <description>
            Performs simple, uncoordinated nearest-frontier exploration.
        </description>
    </class>
</library>

My CMakeLists.txt file:

cmake_minimum_required(VERSION 2.8.3)
project(frontier_exploration)

find_package(catkin REQUIRED
    COMPONENTS
    geometry_msgs
    nav2d_navigator
    nav_msgs
    pluginlib
    roscpp
    visualization_msgs
    tf 
    std_msgs
)

catkin_package(LIBRARIES
    ExplorationPlugins
    CATKIN_DEPENDS
    roscpp
    tf
    pluginlib
    geometry_msgs
    nav_msgs
    visualization_msgs
    nav2d_navigator
    std_msgs 
)

include_directories(include/${PROJECT_NAME}/${catkin_INCLUDE_DIRS})

add_library(FrontierPlugins src/NearestBasedAllocation.cpp)
add_dependencies(FrontierPlugins ${catkin_EXPORTED_TARGETS})
target_link_libraries(FrontierPlugins ${catkin_LIBRARIES})

install(TARGETS FrontierPlugins  
    LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION})

install(FILES frontier.xml  
    DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})

Can anyone please help me with the reason why I am unable to load these plugins? Thanks

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-03-21 18:22:36 -0500

jclinton830 gravatar image

updated 2019-07-10 01:01:40 -0500

jayess gravatar image

Hey I am sure you have figured out the answer to this, just to make sure that others are able to find the answer easily here is what is causing the issue.

Registering/Exporting a Plugin

In order to allow a class to be dynamically loaded, it must be marked as an exported class. This is done through the special macro PLUGINLIB_EXPORT_CLASS. This macro can be put into any source (.cpp) file that composes the plugin library, but is usually put at the end of the .cpp file for the exported class. For the example above, we might create a class_list.cpp file in package example_pkg that looks as follows and compile it into the librectangle library. In your case your cpp should have something like this at the top

#include <pluginlib/class_list_macros.h>
#include <FrontierPlugins/NearestBasedAllocation.h>

PLUGINLIB_EXPORT_CLASS(FrontierPlugins::NearestBasedAllocation, YourBaseClassNamespace::YourBaseClass)
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-11-04 20:21:32 -0500

Seen: 1,903 times

Last updated: Jul 10 '19