ros2
module_error
ai_generated
true
[component_container_isolated]: Failed to load component: Failed to find class with name 'my_pkg::MyComponent': No matching class found in library
ID: ros2/component-container-mismatch
90%Fix Rate
87%Confidence
1Evidence
2023-06-22First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| ROS2 Humble | active | — | — | — |
| ROS2 Iron | active | — | — | — |
| ROS2 Jazzy | active | — | — | — |
Root Cause
The component class is either not registered with the RCLCPP_COMPONENTS_REGISTER_NODE macro, or the library was not built/linked correctly, so the container cannot instantiate it at runtime.
generic中文
组件类未使用RCLCPP_COMPONENTS_REGISTER_NODE宏注册,或者库未正确构建/链接,导致容器在运行时无法实例化它。
Official Documentation
https://docs.ros.org/en/humble/Tutorials/Intermediate/Composition.htmlWorkarounds
-
95% success Ensure the component source file includes the registration macro: 'RCLCPP_COMPONENTS_REGISTER_NODE(my_pkg::MyComponent)' and that the CMakeLists.txt uses 'add_library' with 'ament_target_dependencies' and 'pluginlib_export_plugin_description_file' if needed.
Ensure the component source file includes the registration macro: 'RCLCPP_COMPONENTS_REGISTER_NODE(my_pkg::MyComponent)' and that the CMakeLists.txt uses 'add_library' with 'ament_target_dependencies' and 'pluginlib_export_plugin_description_file' if needed.
-
85% success Check the library exports: 'nm -C libmy_component.so | grep MyComponent' to see if the symbol is present. If not, rebuild with 'colcon build --cmake-args -DCMAKE_BUILD_TYPE=Debug' and check for missing dependencies.
Check the library exports: 'nm -C libmy_component.so | grep MyComponent' to see if the symbol is present. If not, rebuild with 'colcon build --cmake-args -DCMAKE_BUILD_TYPE=Debug' and check for missing dependencies.
-
90% success Verify the component's plugin description XML file (e.g., 'my_component_plugins.xml') is correctly formatted and referenced in 'package.xml' under <export>.
Verify the component's plugin description XML file (e.g., 'my_component_plugins.xml') is correctly formatted and referenced in 'package.xml' under <export>.
中文步骤
确保组件源文件包含注册宏:'RCLCPP_COMPONENTS_REGISTER_NODE(my_pkg::MyComponent)',并且CMakeLists.txt使用'add_library',必要时包含'ament_target_dependencies'和'pluginlib_export_plugin_description_file'。
检查库导出:'nm -C libmy_component.so | grep MyComponent'以查看符号是否存在。如果不存在,使用'colcon build --cmake-args -DCMAKE_BUILD_TYPE=Debug'重新构建并检查缺失的依赖。
验证组件的插件描述XML文件(如'my_component_plugins.xml')格式正确,并在'package.xml'的<export>部分中引用。
Dead Ends
Common approaches that don't work:
-
Adding the component source file to a different package's CMakeLists.txt without proper registration
90% fail
The class must be registered in the same library where it is built, using the correct macro. Moving files without registration does not help.
-
Manually loading the library with 'dlopen' in the container to verify it exists
60% fail
The library may exist but the class registration may still be missing. This does not fix the registration issue.