Skip to content

Move DiagnosticRecoveryManager reference components to their own library - #189

Open
estherag wants to merge 1 commit into
EasyNavigation:rollingfrom
estherag:drm-components-library
Open

estherag wants to merge 1 commit into
EasyNavigation:rollingfrom
estherag:drm-components-library

Conversation

@estherag

Copy link
Copy Markdown
Contributor

Dear EasyNavers,

I'm writing my own recovery manager, a RecoveryManagerBase plugin that acts as the EasyNav binding of a run-time adaptation framework, and I'd like it to reuse what the DiagnosticRecoveryManager already provides: the CollisionSafetyReflex, 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:

MultiLibraryClassLoader: Could not create object of class type easynav::NoPathEvaluator as no factory exists for it.

The components live in the same library as the DiagnosticRecoveryManager. When recovery_node loads my plugin, that library is loaded with it, so the components get registered under recovery_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 the DiagnosticRecoveryManager. The existing tests don't catch it because they link the library directly.

Changes

  • New library easynav_diagnostic_recovery_components with the evaluators, mitigations and CollisionSafetyReflex; easynav_diagnostic_recovery keeps the DiagnosticRecoveryManager, the base classes and ObstacleProximity.
  • easynav_diagnostic_recovery_components_plugins.xml points the components to the new library.
  • The component tests link the new library.
  • New component_library_tests: it links neither library (like system_main), loads DummyEvaluator (whose library links the DRM library) with one class loader and then NoPathEvaluator with 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_recovery and uses a concrete component directly would need to link easynav_diagnostic_recovery_components too; I didn't find any in EasyNavigation or easynav_plugins.

Happy to hear opinions!
Esther

@codecov

codecov Bot commented Nov 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@fmrico fmrico left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 the easynav_diagnostic_recovery package 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:

  • DiagnosticRecoveryManager itself 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 because recovery_node loads 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 CollisionSafetyReflex through 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. 🙂

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants