Skip to content

Conversation

shameekganguly
Copy link
Contributor

🎉 New feature

Summary

Gz Plugin added support for loading plugins from statically linked plugin libraries in gazebosim/gz-plugin@a49b9f4.
This PR builds on top of this feature to enable System plugins to be loaded from the static plugin registry.

To indicate that a plugin should be loaded from the static registry, users can specify the sdf plugin@filename attribute as static://<fully qualified plugin class name> or static://<registered plugin alias>. (The plugin@name attribute is unused in this case and can conventionally use the same plugin name or alias stem as the plugin@filename attribute).

I updated the SystemLoader::InstantiateSystemPlugin method to check if the plugin filename conforms to the above pattern and attempt to instantiate the plugin from the static registry in this case. Loading fails if the plugin either cannot be found in the static registry or it does not implement the System interface.

I also added an integration test in test/integration/load_system_static_registry.cc to verify this feature (runs both in cmake and bazel build). This test uses the TestModelSystem test System class that I registered with the static plugin registry in test/plugins/TestStaticModelSystem.cc. Note that the TestStaticModelSystem static library needs to be linked with special flags into the test binary target in cmake to ensure that the plugin class symbols are not stripped out by the linker (similar to this test target in gz plugin).

Test it

bazel:

$ bazel test test:INTEGRATION_load_system_static_registry

cmake:

$ colcon test --merge-install --event-handlers console_direct+ --packages-select gz-sim9 --ctest-args -R INTEGRATION_load*

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • [] All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers
  • Was GenAI used to generate this PR? If so, make sure to add "Generated-by" to your commits. (See this policy for more info.)

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by and Generated-by messages.

Signed-off-by: Shameek Ganguly <shameek@intrinsic.ai>
Signed-off-by: Shameek Ganguly <shameek@intrinsic.ai>
Signed-off-by: Shameek Ganguly <shameek@intrinsic.ai>
@shameekganguly shameekganguly requested a review from iche033 June 13, 2025 21:26
Copy link
Contributor

@iche033 iche033 left a comment

Choose a reason for hiding this comment

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

looks good, just minor style suggestions

add_library(TestStaticModelSystem STATIC TestStaticModelSystem.cc)
target_link_libraries(TestStaticModelSystem PRIVATE
gz-plugin${GZ_PLUGIN_VER}::register
gz-transport${GZ_TRANSPORT_VER}::gz-transport${GZ_TRANSPORT_VER}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think gz-transport is not needed here

Copy link
Contributor Author

@shameekganguly shameekganguly Jun 13, 2025

Choose a reason for hiding this comment

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

I believe it is needed since the plugin implementation in the header file test/plugins/TestModelSystem.hh exposes a gz transport service.

Signed-off-by: Shameek Ganguly <shameek@intrinsic.ai>
@shameekganguly shameekganguly requested a review from iche033 June 13, 2025 23:11
@github-project-automation github-project-automation bot moved this from Inbox to In review in Core development Jun 16, 2025
@iche033 iche033 merged commit 8416a64 into gz-sim9 Jun 16, 2025
14 checks passed
@iche033 iche033 deleted the shameek/static_plugin branch June 16, 2025 20:34
@github-project-automation github-project-automation bot moved this from In review to Done in Core development Jun 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🏛️ ionic Gazebo Ionic

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants