Skip to content

Commit

Permalink
Allow "drilling down" into nested model frames (#381)
Browse files Browse the repository at this point in the history
* Expect nested_explicit_canonical_link.sdf is valid

Split nested_invalid_explicit_canonical_link.sdf
into nested_explicit_canonical_link.sdf and
nested_without_links_invalid.sdf and update
UNIT_ign_TEST and an integration test.

Signed-off-by: Steve Peters <[email protected]>

* Support :: syntax in *NameExists and *ByName APIs

This extends the `Model::*NameExists` and `Model::*ByName` APIs
(like LinkNameExists and LinkByName) that allow passing
nested names that can begin with a sequence of nested model
names separated by :: and may end with the name of an object
of the specified type, such as "outer_model::inner_model::inner_joint".

For now, if a nested model is not found that matches the nested name
preceding the final ::, then it checks for objects in the current model
that match the entire name. This extra check should be disabled
when "::" is reserved and not allowed in frame names.

Signed-off-by: Steve Peters <[email protected]>

* Changelog and Migration guide

Signed-off-by: Steve Peters <[email protected]>

* Ensure CanonicalLink pointer is valid

Signed-off-by: Steve Peters <[email protected]>

* Add ScopedGraph header

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Frame attached to tests passing

Signed-off-by: Addisu Z. Taddese <[email protected]>

* FrameSemantics_TEST passing

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Pass ChildScope with new scope name

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Add command line tool to generate graph

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Avoid using the RawPose of the DOM object when the object is a frame (implicit or explicit)

Instead use the edges in the pose graph. This allows us to update only
the pose graph when handling placement frames.

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Handle placement frames with new PoseRelativeTo construction scheme

The PoseRelativeTo used to be constructed in each nested model's Load
funcition. Now, it's only constructed at the outer most model. Because
of this decoupling and Since the model is `const` when the graph is
constructed, placement frames are handled differently. Instead of
updating the raw pose of the model, the edge connecting the model frame
to it's relative_to frame is modified to take into account the placement
frame.

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Add __root__ scope

The __root__ vertex is the root node of both world and model
PoseRelativeTo graphs. It corresponds to the `<sdf>` tag in SDFormat
files. Having this node makes it possible to keep the a model's pose and
(possibly accounting for placement_frame) information in the edge from
the _root__ vertex to the model vertex.

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Revert changes in loadUniqueRepeated

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Make ScopedGraph use pointer semantics

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Cleanup

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Remove `__root__` scope name

The `__root__` vertex still exits, but has either a `__model__` scope or
a `world` scope.

Signed-off-by: Addisu Z. Taddese <[email protected]>

* SemanticPose::Resolve and JointAxis::ResolveXyz to a SemanticPose object to set the scope

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Add missing file

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Remove aliasing edges, there is no need for them. Also remove updateGraphPose

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Refactor

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Cleanup

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Add Resolve function that takes DOM objects

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Add test for placement attribute with nested link

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Codecheck

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Fix macOS build error

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Add nested model pose relative_to test

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Add nested model frame attached_to test

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Add test for joints that reference entities in nested models

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Add API documentation for ScopedGraph, refactor

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Add test for placement_frame element that references nested frames

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Add test for empty models that contain a nested static model

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Resolve SemanticPose objects relative to other SemanticPose objects

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Add missing file

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Revert the SemanticPose::Resolve API that takes SemanticPose objects

This proved to be problematic since the graph contained in the input
SemanticPose can be at a different scope than the graph in the current
object. Thus it becomes necessary to find the least common ancestor
vertex between two vertices in the graph. This is feasible, but it would
be best to do it in a separate PR.

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Remove addNestedModel

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Add more documentation, cleanup

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Validate __root__ vertices

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Add more error cases in validate* functions

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Remove obsolete test

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Prevent users from referencing `__root__` in SDFormat XML.

Signed-off-by: Addisu Z. Taddese <[email protected]>

* More expectations in LoadJointNestedParentChild

Test `Joint::Resolve*Link` methods in LoadJointNestedParentChild
test case.

Signed-off-by: Steve Peters <[email protected]>

* Address Reviewer feedback

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Add and update doxygen for SetFrameAttachedToGraph and SetPoseRelativeToGraph

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Add doxygen to new SemanticPose constructor

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Remove unnecessary code

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Refactor code that handles PlacementFrame into a function

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Address reviewer feedback

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Add failing test showing bug in checkFrameAttachedToNames

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Fix how frame attached_to names are checked for existence

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Add unit test for the output stream of sdf::Errors

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Return void from Model::SetPoseRelativeToGraph

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Add test for world level nested references

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Add test for ign graph command

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Be more selective about checking for usage of __root__

Instead of checking if any attribute has a value of "__root__", only the
following attributes are checked:
  * //frame/[@attached_to]
  * //pose/[@relative_to]
  * //model/[@placement_frame]
  * //model/[@canonical_link]
  * //sensor/imu/orientation_reference_frame/custom_rpy/[@parent_frame]

In addition, the elements //joint/parent, //joint/child and
//include/placement_frame are checked for validity

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Address reviewer feedback

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Scoped -> scoped

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Address reviewer feedback

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Change scopeName to scopeContextName

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Add warning to the help message of ign sdf -g command

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Remove extraneous error comments

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Address reviewer feedback

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Resolve additional merge conflicts

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Cleanup

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Address reviewer feedback

Signed-off-by: Addisu Z. Taddese <[email protected]>

* State that *Count functions only count immediate child elements

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Address reviewer feedback

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Typo

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Revert documentation updates to Root::*ByName and World::*ByName functions

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Keep some of the changes from the previous commit

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Move construction of PoseRelativeToGraph and FrameAttachedToGraph to sdf::Root (#1)

* Move graph creation to sdf::Root from sdf::World and sdf::Model.

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Convert ScopedGraph to hold a strong reference to the underlying graph

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Add copy/move constructors to sdf::Root

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Additional test of sdf::Root objects before copy and move

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Fix typo

Signed-off-by: Addisu Z. Taddese <[email protected]>

* Explicitly delete copy constructor and assignment.

Signed-off-by: Addisu Z. Taddese <[email protected]>

Co-authored-by: Steve Peters <[email protected]>
  • Loading branch information
azeey and scpeters authored Nov 18, 2020
1 parent 0093747 commit 5a91081
Show file tree
Hide file tree
Showing 65 changed files with 3,700 additions and 1,673 deletions.
7 changes: 4 additions & 3 deletions Migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ but with improved human-readability..

### Modifications

1. **sdf/Model.hh**: the following methods now accept nested names
that can begin with a sequence of nested model names separated
by `::` and may end with the name of an object of the specified type.
1. **sdf/Model.hh**: the following methods now accept nested names relative to
the model's scope that can begin with a sequence of nested model names
separated by `::` and may end with the name of an object of the specified
type.
+ const Frame \*FrameByName(const std::string &) const
+ const Joint \*JointByName(const std::string &) const
+ const Link \*LinkByName(const std::string &) const
Expand Down
9 changes: 5 additions & 4 deletions include/sdf/Collision.hh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ namespace sdf
class Geometry;
class Surface;
struct PoseRelativeToGraph;
template <typename T> class ScopedGraph;

/// \brief A collision element descibes the collision properties associated
/// with a link. This can be different from the visual properties of a link.
Expand Down Expand Up @@ -141,12 +142,12 @@ namespace sdf
/// \param[in] _xmlParentName Name of xml parent object.
private: void SetXmlParentName(const std::string &_xmlParentName);

/// \brief Give a weak pointer to the PoseRelativeToGraph to be used
/// for resolving poses. This is private and is intended to be called by
/// \brief Give the scoped PoseRelativeToGraph to be used for resolving
/// poses. This is private and is intended to be called by
/// Link::SetPoseRelativeToGraph.
/// \param[in] _graph Weak pointer to PoseRelativeToGraph.
/// \param[in] _graph scoped PoseRelativeToGraph object.
private: void SetPoseRelativeToGraph(
std::weak_ptr<const PoseRelativeToGraph> _graph);
sdf::ScopedGraph<PoseRelativeToGraph> _graph);

/// \brief Allow Link::SetPoseRelativeToGraph to call SetXmlParentName
/// and SetPoseRelativeToGraph, but Link::SetPoseRelativeToGraph is
Expand Down
26 changes: 13 additions & 13 deletions include/sdf/Frame.hh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ namespace sdf
class FramePrivate;
struct FrameAttachedToGraph;
struct PoseRelativeToGraph;
template <typename T> class ScopedGraph;

/// \brief A Frame element descibes the properties associated with an
/// explicit frame defined in a Model or World.
Expand Down Expand Up @@ -133,9 +134,8 @@ namespace sdf
public: sdf::ElementPtr Element() const;

/// \brief Resolve the attached-to body of this frame from the
/// FrameAttachedToGraph. If this is in a __model__ scope, it returns
/// the name of a link. In the world scope, it returns the name of a
/// model or the world.
/// FrameAttachedToGraph. Generally, it resolves to the name of a link, but
/// if it is in the world scope, it can resolve to "world".
/// \param[out] _body Name of body to which this frame is attached.
/// \return Errors.
public: Errors ResolveAttachedToBody(std::string &_body) const;
Expand All @@ -145,19 +145,19 @@ namespace sdf
/// \return SemanticPose object for this link.
public: sdf::SemanticPose SemanticPose() const;

/// \brief Give a weak pointer to the FrameAttachedToGraph to be used
/// for resolving attached bodies. This is private and is intended to
/// be called by Model::Load or World::Load.
/// \param[in] _graph Weak pointer to FrameAttachedToGraph.
/// \brief Give a scoped FrameAttachedToGraph to be used for resolving
/// attached bodies. This is private and is intended to be called by
/// Model::Load or World::Load.
/// \param[in] _graph scoped FrameAttachedToGraph object.
private: void SetFrameAttachedToGraph(
std::weak_ptr<const FrameAttachedToGraph> _graph);
sdf::ScopedGraph<FrameAttachedToGraph> _graph);

/// \brief Give a weak pointer to the PoseRelativeToGraph to be used
/// for resolving poses. This is private and is intended to be called by
/// Model::Load or World::Load.
/// \param[in] _graph Weak pointer to PoseRelativeToGraph.
/// \brief Give the scoped PoseRelativeToGraph to be used for resolving
/// poses. This is private and is intended to be called by Model::Load or
/// World::Load.
/// \param[in] _graph scoped PoseRelativeToGraph object.
private: void SetPoseRelativeToGraph(
std::weak_ptr<const PoseRelativeToGraph> _graph);
sdf::ScopedGraph<PoseRelativeToGraph> _graph);

/// \brief Allow Model::Load and World::Load to call SetPoseRelativeToGraph.
friend class Model;
Expand Down
20 changes: 10 additions & 10 deletions include/sdf/Joint.hh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ namespace sdf
class JointPrivate;
struct FrameAttachedToGraph;
struct PoseRelativeToGraph;
template <typename T> class ScopedGraph;

/// \enum JointType
/// \brief The set of joint types. INVALID indicates that joint type has
Expand Down Expand Up @@ -221,19 +222,18 @@ namespace sdf
/// \return SemanticPose object for this link.
public: sdf::SemanticPose SemanticPose() const;

/// \brief Give a weak pointer to the FrameAttachedToGraph to be used
/// for resolving parent and child link names. This is private and is
/// intended to be called by Model::Load.
/// \param[in] _graph Weak pointer to FrameAttachedToGraph.
/// \brief Give the scoped FrameAttachedToGraph to be used for resolving
/// parent and child link names. This is private and is intended to be
/// called by Model::Load.
/// \param[in] _graph scoped FrameAttachedToGraph object.
private: void SetFrameAttachedToGraph(
std::weak_ptr<const FrameAttachedToGraph> _graph);
sdf::ScopedGraph<FrameAttachedToGraph> _graph);

/// \brief Give a weak pointer to the PoseRelativeToGraph to be used
/// for resolving poses. This is private and is intended to be called by
/// Model::Load.
/// \param[in] _graph Weak pointer to PoseRelativeToGraph.
/// \brief Give the scoped PoseRelativeToGraph to be used for resolving
/// poses. This is private and is intended to be called by Model::Load.
/// \param[in] _graph scoped PoseRelativeToGraph object.
private: void SetPoseRelativeToGraph(
std::weak_ptr<const PoseRelativeToGraph> _graph);
sdf::ScopedGraph<PoseRelativeToGraph> _graph);

/// \brief Allow Model::Load to call SetPoseRelativeToGraph.
friend class Model;
Expand Down
11 changes: 6 additions & 5 deletions include/sdf/JointAxis.hh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ namespace sdf
// Forward declare private data class.
class JointAxisPrivate;
struct PoseRelativeToGraph;
template <typename T> class ScopedGraph;

/// \brief Parameters related to the axis of rotation for rotational joints,
/// and the axis of translation for prismatic joints.
Expand Down Expand Up @@ -269,12 +270,12 @@ namespace sdf
/// \param[in] _xmlParentName Name of xml parent object.
private: void SetXmlParentName(const std::string &_xmlParentName);

/// \brief Give a weak pointer to the PoseRelativeToGraph to be used
/// for resolving poses. This is private and is intended to be called
/// by Joint::SetPoseRelativeToGraph.
/// \param[in] _graph Weak pointer to PoseRelativeToGraph.
/// \brief Give the scoped PoseRelativeToGraph to be used for resolving
/// poses. This is private and is intended to be called by
/// Joint::SetPoseRelativeToGraph.
/// \param[in] _graph scoped PoseRelativeToGraph object.
private: void SetPoseRelativeToGraph(
std::weak_ptr<const PoseRelativeToGraph> _graph);
sdf::ScopedGraph<PoseRelativeToGraph> _graph);

/// \brief Allow Joint::SetPoseRelativeToGraph to propagate.
friend class Joint;
Expand Down
9 changes: 5 additions & 4 deletions include/sdf/Light.hh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ namespace sdf
// Forward declare private data class.
class LightPrivate;
struct PoseRelativeToGraph;
template <typename T> class ScopedGraph;

/// \enum LightType
/// \brief The set of light types. INVALID indicates that light type has
Expand Down Expand Up @@ -273,12 +274,12 @@ namespace sdf
/// \param[in] _xmlParentName Name of xml parent object.
private: void SetXmlParentName(const std::string &_xmlParentName);

/// \brief Give a weak pointer to the PoseRelativeToGraph to be used
/// for resolving poses. This is private and is intended to be called by
/// \brief Give the scoped PoseRelativeToGraph to be used for resolving
/// poses. This is private and is intended to be called by
/// Link::SetPoseRelativeToGraph or World::Load.
/// \param[in] _graph Weak pointer to PoseRelativeToGraph.
/// \param[in] _graph scoped PoseRelativeToGraph object.
private: void SetPoseRelativeToGraph(
std::weak_ptr<const PoseRelativeToGraph> _graph);
sdf::ScopedGraph<PoseRelativeToGraph> _graph);

/// \brief Allow Link::SetPoseRelativeToGraph or World::Load to call
/// SetXmlParentName and SetPoseRelativeToGraph,
Expand Down
10 changes: 5 additions & 5 deletions include/sdf/Link.hh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ namespace sdf
class Visual;
class LinkPrivate;
struct PoseRelativeToGraph;
template <typename T> class ScopedGraph;

class SDFORMAT_VISIBLE Link
{
Expand Down Expand Up @@ -225,12 +226,11 @@ namespace sdf
/// \return SemanticPose object for this link.
public: sdf::SemanticPose SemanticPose() const;

/// \brief Give a weak pointer to the PoseRelativeToGraph to be used
/// for resolving poses. This is private and is intended to be called by
/// Model::Load.
/// \param[in] _graph Weak pointer to PoseRelativeToGraph.
/// \brief Give the scoped PoseRelativeToGraph to be used for resolving
/// poses. This is private and is intended to be called by Model::Load.
/// \param[in] _graph scoped PoseRelativeToGraph object.
private: void SetPoseRelativeToGraph(
std::weak_ptr<const PoseRelativeToGraph> _graph);
sdf::ScopedGraph<PoseRelativeToGraph> _graph);

/// \brief Allow Model::Load to call SetPoseRelativeToGraph.
friend class Model;
Expand Down
61 changes: 44 additions & 17 deletions include/sdf/Model.hh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ namespace sdf
class Link;
class ModelPrivate;
struct PoseRelativeToGraph;
struct FrameAttachedToGraph;
template <typename T> class ScopedGraph;

class SDFORMAT_VISIBLE Model
{
Expand Down Expand Up @@ -132,11 +134,14 @@ namespace sdf
/// should be subject to wind.
public: void SetEnableWind(bool _enableWind);

/// \brief Get the number of links.
/// \brief Get the number of links that are immediate (not nested) children
/// of this Model object.
/// \remark LinkByName() can find links that are not immediate children of
/// this Model object.
/// \return Number of links contained in this Model object.
public: uint64_t LinkCount() const;

/// \brief Get a link based on an index.
/// \brief Get an immediate (not nested) child link based on an index.
/// \param[in] _index Index of the link. The index should be in the
/// range [0..LinkCount()).
/// \return Pointer to the link. Nullptr if the index does not exist.
Expand All @@ -157,11 +162,14 @@ namespace sdf
/// \return True if there exists a link with the given name.
public: bool LinkNameExists(const std::string &_name) const;

/// \brief Get the number of joints.
/// \brief Get the number of joints that are immediate (not nested) children
/// of this Model object.
/// \remark JointByName() can find joints that are not immediate children of
/// this Model object.
/// \return Number of joints contained in this Model object.
public: uint64_t JointCount() const;

/// \brief Get a joint based on an index.
/// \brief Get an immediate (not nested) child joint based on an index.
/// \param[in] _index Index of the joint. The index should be in the
/// range [0..JointCount()).
/// \return Pointer to the joint. Nullptr if the index does not exist.
Expand All @@ -170,7 +178,7 @@ namespace sdf

/// \brief Get whether a joint name exists.
/// \param[in] _name Name of the joint to check.
/// To check for a joint in a nested model, prefix the link name with
/// To check for a joint in a nested model, prefix the joint name with
/// the sequence of nested models containing this joint, delimited by "::".
/// \return True if there exists a joint with the given name.
public: bool JointNameExists(const std::string &_name) const;
Expand All @@ -184,11 +192,15 @@ namespace sdf
/// \sa bool JointNameExists(const std::string &_name) const
public: const Joint *JointByName(const std::string &_name) const;

/// \brief Get the number of explicit frames.
/// \brief Get the number of explicit frames that are immediate (not nested)
/// children of this Model object.
/// \remark FrameByName() can find explicit frames that are not immediate
/// children of this Model object.
/// \return Number of explicit frames contained in this Model object.
public: uint64_t FrameCount() const;

/// \brief Get an explicit frame based on an index.
/// \brief Get an immediate (not nested) child explicit frame based on an
/// index.
/// \param[in] _index Index of the explicit frame. The index should be in
/// the range [0..FrameCount()).
/// \return Pointer to the explicit frame. Nullptr if the index does not
Expand All @@ -211,11 +223,15 @@ namespace sdf
/// \return True if there exists an explicit frame with the given name.
public: bool FrameNameExists(const std::string &_name) const;

/// \brief Get the number of nested models.
/// \brief Get the number of nested models that are immediate (not
/// recursively nested) children of this Model object.
/// \remark ModelByName() can find nested models that are not immediate
/// children of this Model object.
/// \return Number of nested models contained in this Model object.
public: uint64_t ModelCount() const;

/// \brief Get a nested model based on an index.
/// \brief Get an immediate (not recursively nested) child model based on an
/// index.
/// \param[in] _index Index of the nested model. The index should be in the
/// range [0..ModelCount()).
/// \return Pointer to the model. Nullptr if the index does not exist.
Expand Down Expand Up @@ -298,13 +314,21 @@ namespace sdf
/// \param[in] _name Name of the placement frame.
public: void SetPlacementFrameName(const std::string &_name);

/// \brief Give a weak pointer to the PoseRelativeToGraph to be used
/// for resolving poses. This is private and is intended to be called by
/// World::Load and Model::Load if this is a nested model.
/// \param[in] _graph Weak pointer to PoseRelativeToGraph.
/// \return Error if graph pointer is invalid.
private: sdf::Errors SetPoseRelativeToGraph(
std::weak_ptr<const PoseRelativeToGraph> _graph);
/// \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
/// Model::SetPoseRelativeToGraph if this is a nested model.
/// \param[in] _graph scoped PoseRelativeToGraph object.
private: void SetPoseRelativeToGraph(
sdf::ScopedGraph<PoseRelativeToGraph> _graph);

/// \brief Give the scoped FrameAttachedToGraph to be used for resolving
/// attached bodies. This is private and is intended to be called by
/// Root::Load or World::SetFrameAttachedToGraph if this is a standalone
/// model and Model::SetFrameAttachedToGraph if this is a nested model.
/// \param[in] _graph scoped FrameAttachedToGraph object.
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 "::".
Expand All @@ -313,7 +337,10 @@ namespace sdf
private: std::pair<const Link *, std::string> CanonicalLinkAndRelativeName()
const;

/// \brief Allow World::Load to call SetPoseRelativeToGraph.
/// \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
Expand Down
20 changes: 19 additions & 1 deletion include/sdf/Root.hh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,23 @@ namespace sdf
/// \brief Default constructor
public: Root();

/// \brief Copy constructor is explicitly deleted to avoid copying the
/// FrameAttachedToGraph and PoseRelativeToGraphs contained in Root.
public: Root(const Root &_root) = delete;

/// \brief Move constructor
/// \param[in] _root Root to move.
public: Root(Root &&_root) noexcept;

/// \brief Move assignment operator.
/// \param[in] _root Root to move.
/// \return Reference to this.
public: Root &operator=(Root &&_root) noexcept;

/// \brief Copy assignment operator is explicitly deleted to avoid copying
/// the FrameAttachedToGraph and PoseRelativeToGraphs contained in Root.
public: Root &operator=(const Root &_root) = delete;

/// \brief Destructor
public: ~Root();

Expand Down Expand Up @@ -107,7 +124,8 @@ namespace sdf
/// \return True if there exists a world with the given name.
public: bool WorldNameExists(const std::string &_name) const;

/// \brief Get the number of models.
/// \brief Get the number of models that are immediate (not nested) children
/// of this Root object.
/// \return Number of models contained in this Root object.
public: uint64_t ModelCount() const;

Expand Down
Loading

0 comments on commit 5a91081

Please sign in to comment.