From 983e8fae73ace20897c97dffacbd00fb0ec01ccc Mon Sep 17 00:00:00 2001 From: "Addisu Z. Taddese" Date: Thu, 3 Dec 2020 10:39:48 -0600 Subject: [PATCH] Make sdf::Model::CanonicalLinkAndRelativeName public (#426) This member function is the only way to obtain the relative name of the canonical link when the link is implicitly nested, i.e, the //model/@canonical_link attribute is empty and the canonical link resolves to a link nested in a child model. While `sdf::Model::CanonicalLink` can be used to resolve the link, the returned `sdf::Link*` can only provide the local (non-relative) name of the link. Signed-off-by: Addisu Z. Taddese --- Migration.md | 3 +++ include/sdf/Model.hh | 19 +++++++------------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/Migration.md b/Migration.md index 313586594..fa25735bd 100644 --- a/Migration.md +++ b/Migration.md @@ -20,6 +20,9 @@ but with improved human-readability.. + Errors ResolveChildLink(std::string&) const + Errors ResolveParentLink(std::string&) const +1. **sdf/Model.hh**: + + std::pair CanonicalLinkAndRelativeName() const; + ### Modifications 1. **sdf/Model.hh**: the following methods now accept nested names relative to diff --git a/include/sdf/Model.hh b/include/sdf/Model.hh index b581aa9f2..96885ac45 100644 --- a/include/sdf/Model.hh +++ b/include/sdf/Model.hh @@ -314,6 +314,13 @@ namespace sdf /// \param[in] _name Name of the placement frame. public: void SetPlacementFrameName(const std::string &_name); + /// \brief Get the model's canonical link and the nested name of the link + /// relative to the current model, delimited by "::". + /// \return An immutable pointer to the canonical link and the nested + /// name of the link relative to the current model. + public: std::pair CanonicalLinkAndRelativeName() + const; + /// \brief Give the scoped PoseRelativeToGraph to be used for resolving /// poses. This is private and is intended to be called by Root::Load or /// World::SetPoseRelativeToGraph if this is a standalone model and @@ -330,24 +337,12 @@ namespace sdf private: void SetFrameAttachedToGraph( sdf::ScopedGraph _graph); - /// \brief Get the model's canonical link and the nested name of the link - /// relative to the current model, delimited by "::". - /// \return An immutable pointer to the canonical link and the nested - /// name of the link relative to the current model. - private: std::pair CanonicalLinkAndRelativeName() - const; - /// \brief Allow Root::Load, World::SetPoseRelativeToGraph, or /// World::SetFrameAttachedToGraph to call SetPoseRelativeToGraph and /// SetFrameAttachedToGraph friend class Root; friend class World; - /// \brief Allow helper function in FrameSemantics.cc to call - /// CanonicalLinkAndRelativeName. - friend std::pair - modelCanonicalLinkAndRelativeName(const Model *); - /// \brief Private data pointer. private: ModelPrivate *dataPtr = nullptr; };