Repository navigation
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
fmrico
left a comment
There was a problem hiding this comment.
Thanks Esther, this is a really nice catch and a clean fix.
The diagnosis is right. It's the classic class_loader limitation with plugin libraries that aren't "pure": if a library that registers plugins gets loaded as a link dependency of another plugin, its factories are bound to the class loader that was loading at that moment. Later, when the DRM's own loader opens the same library, nothing new gets registered, so we get "no factory exists". The new layout fixes it at the root: the base library has the DRM and the interfaces, and the components live in a library that only pluginlib loads. I also like that component_library_tests reproduces the real scenario without linking either library. The existing tests could never have caught this.
I checked the downstream users I know of. In easynav_costmap_localizer, amcl_convergence_evaluator and amcl_relocalize_mitigation link easynav_diagnostic_recovery but only use the base classes, so nothing breaks.
One request before merging:
README.md, Package layout: it still says "Everything is in theeasynav_diagnostic_recoverypackage and library". Could you describe the two libraries there? Something like: the base library (DRM, the three interfaces,ObstacleProximity) is what a custom recovery manager, or one that inherits from the DRM, should link; the components library holds the reference reflexes, evaluators and mitigations and is meant to be loaded through pluginlib. It's useful information for people writing their own manager, as you are.
Optional, up to you:
DiagnosticRecoveryManageritself is still exported from the base library, so a custom manager that links it also registers the DRM class as a side effect. That's harmless becauserecovery_nodeloads a single manager, but a short note in the CMake comment could save someone a debugging session later.- The test could also create one mitigation and the
CollisionSafetyReflexthrough their own loaders. They're in the same library, so this isn't really needed, but it would cover all three interfaces.
LGTM once the README is updated. 🙂
Dear EasyNavers,
I'm writing my own recovery manager, a
RecoveryManagerBaseplugin that acts as the EasyNav binding of a run-time adaptation framework, and I'd like it to reuse what theDiagnosticRecoveryManageralready provides: theCollisionSafetyReflex, some evaluators as symptom sources, and a few mitigations.However, once my plugin links
easynav_diagnostic_recovery(it needs the base classes), pluginlib can no longer create those components:The components live in the same library as the
DiagnosticRecoveryManager. Whenrecovery_nodeloads my plugin, that library is loaded with it, so the components get registered underrecovery_node's class loader; the class loader my manager uses for its components then can't create them. This happens both with a manager of my own and with one that inherits from theDiagnosticRecoveryManager. The existing tests don't catch it because they link the library directly.Changes
easynav_diagnostic_recovery_componentswith the evaluators, mitigations andCollisionSafetyReflex;easynav_diagnostic_recoverykeeps the DiagnosticRecoveryManager, the base classes andObstacleProximity.easynav_diagnostic_recovery_components_plugins.xmlpoints the components to the new library.component_library_tests: it links neither library (likesystem_main), loadsDummyEvaluator(whose library links the DRM library) with one class loader and thenNoPathEvaluatorwith another. It fails with the old layout and passes with the new one.Nothing changes for anyone who loads the DiagnosticRecoveryManager and its components through pluginlib. Code that links
easynav_diagnostic_recoveryand uses a concrete component directly would need to linkeasynav_diagnostic_recovery_componentstoo; I didn't find any in EasyNavigation or easynav_plugins.Happy to hear opinions!
Esther