0
$\begingroup$

Rosanswers logo

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


Originally posted by robo_explorer on ROS Answers with karma: 29 on 2015-11-04

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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)

Originally posted by jclinton830 with karma: 91 on 2019-03-21

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.