Skip to content

Add support for namespace attribute on <model>#1663

Open
C88-YQ wants to merge 12 commits into
gazebosim:mainfrom
C88-YQ:ns_support_model
Open

Add support for namespace attribute on <model>#1663
C88-YQ wants to merge 12 commits into
gazebosim:mainfrom
C88-YQ:ns_support_model

Conversation

@C88-YQ

@C88-YQ C88-YQ commented Jun 8, 2026

Copy link
Copy Markdown

🎉 New feature

Related to #1659

Summary

Add support for namespace attribute on <model> and expose it through the sdf::Model.

This change adds:

  • A new optional namespace attribute in the SDF 1.12 model schema.

  • sdf::Model::Namespace(), RawNamespace(), and SetNamespace().

  • Support for the __name__ placeholder in namespace strings, which is resolved using the model name.

  • Support for overriding an included model's namespace with <include><namespace>...</namespace></include>.

    With this, a model can define its own namespace:

    <model name="robot1" namespace="__name__/ns">
      ...
    </model>

    and an include can override it:

    <include>
      <uri>model://robot</uri>
      <name>robot2</name>
      <namespace>robot2</namespace>
    </include>
    

Test it

ctest -R "Model|includes|interface_api"

Checklist

  • Signed all commits for DCO
  • Added a screen capture or video to the PR description that demonstrates the feature
  • 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)
  • Updated Bazel files (if adding new files). Created an issue otherwise.
  • 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.)

C88-YQ added 8 commits June 5, 2026 13:33
Signed-off-by: C88-YQ <1409947012@qq.com>
Signed-off-by: C88-YQ <1409947012@qq.com>
Signed-off-by: C88-YQ <1409947012@qq.com>
Signed-off-by: C88-YQ <1409947012@qq.com>
Signed-off-by: C88-YQ <1409947012@qq.com>
Signed-off-by: C88-YQ <1409947012@qq.com>
Signed-off-by: C88-YQ <1409947012@qq.com>
Signed-off-by: C88-YQ <1409947012@qq.com>

@azeey azeey left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@scpeters We're hoping to add the namespace attribute and backport it to older versions (up to Harmonic). I know we don't have a clear policy on adding things to the spec in older versions so I'd like to know what your opinion is on this.

Comment thread sdf/1.12/model.sdf Outdated
Comment thread src/parser.cc
Comment thread src/Model.cc Outdated
Comment thread src/Model.cc Outdated
Comment thread include/sdf/Model.hh Outdated
Comment thread include/sdf/Model.hh Outdated
Comment thread src/Model.cc Outdated
Comment thread sdf/1.12/model.sdf
C88-YQ added 3 commits June 12, 2026 08:52
Signed-off-by: C88-YQ <1409947012@qq.com>
Signed-off-by: C88-YQ <1409947012@qq.com>
Signed-off-by: C88-YQ <1409947012@qq.com>
Signed-off-by: C88-YQ <1409947012@qq.com>
@cheriehu

Copy link
Copy Markdown

The tests pass for me as well! Can I check if there's a corresponding gz-sim branch to test this with?

@C88-YQ

C88-YQ commented Jun 26, 2026

Copy link
Copy Markdown
Author

@cheriehu Thanks for testing!

Yes, there is a corresponding gz-sim PR / branch for this work: gazebosim/gz-sim#3669

However, this branch currently includes changes for several related features, and we are planning to split it into several smaller PRs later to make the changes easier to review and test separately.

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

Projects

Status: Inbox

Development

Successfully merging this pull request may close these issues.

3 participants