ros2 runtime_error ai_generated true

pluginlib::ClassLoader: Unable to find class 'my_plugin/MyPlugin'

ID: ros2/pluginlib-class-not-found

Also available as: JSON · Markdown
85%Fix Rate
88%Confidence
3Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
2 active

Root Cause

pluginlib cannot find the plugin class. Usually a missing export in package.xml or wrong plugin description XML.

generic

Workarounds

  1. 92% success Verify plugin is exported in package.xml with <pluginlib> tag
    <export><pluginlib plugin="${prefix}/plugins.xml" /></export>
  2. 88% success Check plugins.xml has correct library path and class name
    <class name="my_ns/MyPlugin" type="my_ns::MyPlugin" base_class_type="base_ns::Base">
  3. 85% success Rebuild and re-source after modifying plugin registration
    colcon build --packages-select my_plugin_pkg && source install/setup.bash

Dead Ends

Common approaches that don't work:

  1. Add the plugin .so to LD_LIBRARY_PATH manually 85% fail

    pluginlib uses its own class registry, not LD_LIBRARY_PATH; the plugin must be exported via package.xml

  2. Copy the plugin XML from another package 78% fail

    Plugin XML must reference the exact library name and class from your package