Skip to content

Commit

Permalink
Make sdf::Model::CanonicalLinkAndRelativeName public (#426)
Browse files Browse the repository at this point in the history
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 <addisu@openrobotics.org>
  • Loading branch information
azeey authored Dec 3, 2020
1 parent a42103e commit 983e8fa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
3 changes: 3 additions & 0 deletions Migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<const Link *, std::string> CanonicalLinkAndRelativeName() const;

### Modifications

1. **sdf/Model.hh**: the following methods now accept nested names relative to
Expand Down
19 changes: 7 additions & 12 deletions include/sdf/Model.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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<const Link *, std::string> 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
Expand All @@ -330,24 +337,12 @@ namespace sdf
private: void SetFrameAttachedToGraph(
sdf::ScopedGraph<FrameAttachedToGraph> _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<const Link *, std::string> 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<const Link *, std::string>
modelCanonicalLinkAndRelativeName(const Model *);

/// \brief Private data pointer.
private: ModelPrivate *dataPtr = nullptr;
};
Expand Down

0 comments on commit 983e8fa

Please sign in to comment.