Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow "drilling down" into nested model frames #381

Merged
merged 75 commits into from
Nov 18, 2020

Conversation

azeey
Copy link
Collaborator

@azeey azeey commented Oct 1, 2020

This a draft PR that adds functionality to allow drilling down into nested models with the :: syntax. This also makes included models work as nested models

Resolves #293, #284
This builds on top of #355


This change is Reviewable

scpeters and others added 16 commits September 3, 2020 12:09
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]>
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]>
Signed-off-by: Steve Peters <[email protected]>
Signed-off-by: Addisu Z. Taddese <[email protected]>
Signed-off-by: Addisu Z. Taddese <[email protected]>
Signed-off-by: Addisu Z. Taddese <[email protected]>
Signed-off-by: Addisu Z. Taddese <[email protected]>
…(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]>
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]>
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]>
Signed-off-by: Addisu Z. Taddese <[email protected]>
@azeey azeey self-assigned this Oct 1, 2020
@EricCousineau-TRI
Copy link
Collaborator

EricCousineau-TRI commented Oct 1, 2020

Per f2f:

  • AT, SP: Semantic pose API, breaking encapsulation?
    • (1) Add arg to ResolvePose() and ResolveXyzAxis() for how many levels up
    • (2) Add SemanticPose.GetView(Level)
      • Have //joint/axis/xyz be expressed as SemanticPose or "SemanticOrientation"
    • (3) Bake "upwards references" into string lookups in ResolvePose() and ResolveXyzAxis()
    • (4) Pass SemanticPose objects directly into ResolvePose() and ResolveXyzAxis()
  • AT: Drilling
    • Add a (private) __root__ frame to cap off root-level models and world
    • Make sure users can't refer to __root__ in XML (e.g. abuse)

Signed-off-by: Addisu Z. Taddese <[email protected]>
The `__root__` vertex still exits, but has either a `__model__` scope or
a `world` scope.

Signed-off-by: Addisu Z. Taddese <[email protected]>
…ect to set the scope

Signed-off-by: Addisu Z. Taddese <[email protected]>
Signed-off-by: Addisu Z. Taddese <[email protected]>
Signed-off-by: Addisu Z. Taddese <[email protected]>
Signed-off-by: Addisu Z. Taddese <[email protected]>
Signed-off-by: Addisu Z. Taddese <[email protected]>
@codecov-io
Copy link

codecov-io commented Oct 8, 2020

Codecov Report

Merging #381 (0a8a7e0) into master (0093747) will increase coverage by 0.31%.
The diff coverage is 89.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #381      +/-   ##
==========================================
+ Coverage   87.40%   87.71%   +0.31%     
==========================================
  Files          60       61       +1     
  Lines        9351     9467     +116     
==========================================
+ Hits         8173     8304     +131     
+ Misses       1178     1163      -15     
Impacted Files Coverage Δ
include/sdf/SemanticPose.hh 100.00% <ø> (ø)
include/sdf/Types.hh 100.00% <ø> (ø)
src/Collision.cc 100.00% <ø> (ø)
src/Light.cc 92.63% <ø> (ø)
src/Sensor.cc 82.07% <ø> (ø)
src/Visual.cc 100.00% <ø> (ø)
src/Utils.hh 96.66% <66.66%> (-3.34%) ⬇️
src/ign.cc 74.41% <77.41%> (+1.69%) ⬆️
src/FrameSemantics.cc 77.82% <84.11%> (+0.21%) ⬆️
src/parser.cc 79.13% <97.72%> (+0.23%) ⬆️
... and 15 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0093747...0a8a7e0. Read the comment docs.

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

@scpeters scpeters left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 3 files at r15.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @azeey)


src/FrameSemantics.cc, line 311 at r14 (raw file):

Previously, azeey (Addisu Z. Taddese) wrote…

The __root__ vertex identifies the scope that contains a root level model. In the PoseRelativeTo graph, this vertex is connected to the model with an edge that holds the value of //model/pose. However, in the FrameAttachedTo graph, the vertex is disconnected because nothing is attached to it. Since only links and static models are allowed to be disconnected in this graph, I chose STATIC_MODEL as its frame type. I could potentially add a different frame type, but that adds more complexity to the validateFrameAttachedToGraph code.

ok, that sounds fine. do you mind adding that justification as a comment in the code?


src/FrameSemantics.cc, line 1348 at r14 (raw file):

Previously, azeey (Addisu Z. Taddese) wrote…

Done in 5c42e39. I also made the outDegree != 0 an else if branch so it isn't taken if the scopeFrameType is not WORLD or STATIC_MODEL.

I see that you made this change in validateFrameAttachedToGraph, but I don't see the change here in validatePoseRelativeToGraph

Signed-off-by: Addisu Z. Taddese <[email protected]>
Signed-off-by: Addisu Z. Taddese <[email protected]>
Copy link
Collaborator Author

@azeey azeey left a comment

Choose a reason for hiding this comment

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

Reviewable status: 60 of 64 files reviewed, 1 unresolved discussion (waiting on @azeey, @EricCousineau-TRI, and @scpeters)


include/sdf/Model.hh, line 191 at r16 (raw file):

Previously, EricCousineau-TRI (Eric Cousineau) wrote…

Not sure if this came up on #355:

Methods like FrameCount() may now be "asymmetric" w.r.t. FrameByName() - i.e. the number of frames reachable by FrameByName() exceeds those indicated by FrameCount().

I think that's fine, but we should clarify that in a comment here, saying that it's only the immediate (not nested frames), and make an explicit mention that FrameByName can reach more.

(Same for link, joint, and nested models)

Thought about this when seeing the unittest mods about flattened models.

Done. Added clarifying comments in f544805.


src/FrameSemantics.cc, line 311 at r14 (raw file):

Previously, scpeters (Steve Peters) wrote…

ok, that sounds fine. do you mind adding that justification as a comment in the code?

Done in 661a502.


src/FrameSemantics.cc, line 1348 at r14 (raw file):

Previously, scpeters (Steve Peters) wrote…

I see that you made this change in validateFrameAttachedToGraph, but I don't see the change here in validatePoseRelativeToGraph

Ah, I missed that one. Done in 661a502.


test/integration/nested_model.cc, line 327 at r16 (raw file):

Previously, EricCousineau-TRI (Eric Cousineau) wrote…

nit xpectations is misspelled

Done in d06275b.

Copy link
Member

@scpeters scpeters left a comment

Choose a reason for hiding this comment

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

Reviewed 4 of 4 files at r17, 1 of 1 files at r18.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @azeey and @EricCousineau-TRI)


include/sdf/Root.hh, line 113 at r17 (raw file):

    /// of this Root object.
    /// \remark ModelNameExists() can find nested models that are not immediate
    /// children of this Root object.

Root::ModelNameExists doesn't actually find nested models; this was enabled for Model::ModelNameExists in #355, but only for the Model class methods


include/sdf/World.hh, line 156 at r17 (raw file):

    /// \param[in] _name Name of the model.
    /// To get a model nested in other models, prefix the model name
    /// with the sequence of nested model names, delimited by "::".

World::ModelByName doesn't actually find nested models; this was enabled for Model::ModelByName in #355, but only for the Model class methods

@azeey
Copy link
Collaborator Author

azeey commented Nov 5, 2020


include/sdf/Root.hh, line 113 at r17 (raw file):

Previously, scpeters (Steve Peters) wrote…

Root::ModelNameExists doesn't actually find nested models; this was enabled for Model::ModelNameExists in #355, but only for the Model class methods

hmm, I hadn't realized that. Do we want to keep it this way or update Root::ModelNameExists and World::ModelNameExists to also work for nested models?

Copy link
Member

@scpeters scpeters left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @azeey and @EricCousineau-TRI)


include/sdf/Root.hh, line 113 at r17 (raw file):

Previously, azeey (Addisu Z. Taddese) wrote…

hmm, I hadn't realized that. Do we want to keep it this way or update Root::ModelNameExists and World::ModelNameExists to also work for nested models?

changing the Root and World APIs wasn't necessary to support explicitly nested canonical links, so I didn't address it in #355. I think it would be reasonable to make all the *ByName and *NameExists APIs work like this, but I'd make an issue for it and not try to include it here

Copy link
Collaborator Author

@azeey azeey left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @EricCousineau-TRI and @scpeters)


include/sdf/Root.hh, line 113 at r17 (raw file):

Previously, scpeters (Steve Peters) wrote…

changing the Root and World APIs wasn't necessary to support explicitly nested canonical links, so I didn't address it in #355. I think it would be reasonable to make all the *ByName and *NameExists APIs work like this, but I'd make an issue for it and not try to include it here

Okay. Created a ticket: #412 and reverted the change in 8b0665a.


include/sdf/World.hh, line 156 at r17 (raw file):

Previously, scpeters (Steve Peters) wrote…

World::ModelByName doesn't actually find nested models; this was enabled for Model::ModelByName in #355, but only for the Model class methods

Reverted in 8b0665a

Copy link
Member

@scpeters scpeters left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r19.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @azeey and @EricCousineau-TRI)


include/sdf/Root.hh, line 113 at r17 (raw file):

    /// \brief Get the number of models that are immediate (not nested) children
    /// of this Root object.

I think this part of the change was ok, since it clarified that the API refers to not-nested children. The \remark was the part that I object to.

Copy link
Collaborator Author

@azeey azeey left a comment

Choose a reason for hiding this comment

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

Reviewable status: 62 of 64 files reviewed, 2 unresolved discussions (waiting on @EricCousineau-TRI and @scpeters)


include/sdf/Root.hh, line 113 at r17 (raw file):

Previously, scpeters (Steve Peters) wrote…
    /// \brief Get the number of models that are immediate (not nested) children
    /// of this Root object.

I think this part of the change was ok, since it clarified that the API refers to not-nested children. The \remark was the part that I object to.

Okay, kept that part of the change in 6390633.

Copy link
Member

@scpeters scpeters left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 2 of 2 files at r20.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @EricCousineau-TRI)

Copy link
Collaborator

@EricCousineau-TRI EricCousineau-TRI left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @azeey)


include/sdf/Model.hh, line 191 at r16 (raw file):

Previously, azeey (Addisu Z. Taddese) wrote…

Done. Added clarifying comments in f544805.

OK Thanks!

Copy link
Collaborator

@EricCousineau-TRI EricCousineau-TRI left a comment

Choose a reason for hiding this comment

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

Reviewed 5 of 8 files at r14, 2 of 4 files at r17, 1 of 1 files at r18, 2 of 2 files at r20.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @azeey)


test/integration/nested_model.cc, line 628 at r20 (raw file):

{
  const std::string testFile =
    sdf::filesystem::append(PROJECT_SOURCE_PATH, "test", "integration",

BTW Did you have a chance to confirm that loading a flattened out model in SDFormat 1.8 fails?

Copy link
Collaborator Author

@azeey azeey left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @azeey)


test/integration/nested_model.cc, line 628 at r20 (raw file):

Previously, EricCousineau-TRI (Eric Cousineau) wrote…

BTW Did you have a chance to confirm that loading a flattened out model in SDFormat 1.8 fails?

No I haven't. Just so I understand, it should pass if the file has version=1.7, but fail if 1.8?

…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]>
Copy link
Collaborator

@EricCousineau-TRI EricCousineau-TRI left a comment

Choose a reason for hiding this comment

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

Reviewable status: 57 of 65 files reviewed, all discussions resolved (waiting on @azeey, @EricCousineau-TRI, and @scpeters)


test/integration/nested_model.cc, line 628 at r20 (raw file):

Previously, azeey (Addisu Z. Taddese) wrote…

No I haven't. Just so I understand, it should pass if the file has version=1.7, but fail if 1.8?

Yup! Feel free to do that as follow-up if you'd like this to merge first!

Copy link
Collaborator Author

@azeey azeey left a comment

Choose a reason for hiding this comment

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

Reviewable status: 57 of 65 files reviewed, all discussions resolved (waiting on @azeey, @EricCousineau-TRI, and @scpeters)


test/integration/nested_model.cc, line 628 at r20 (raw file):

Previously, EricCousineau-TRI (Eric Cousineau) wrote…

Yup! Feel free to do that as follow-up if you'd like this to merge first!

Okay, yeah, I'll go ahead and merge the PR and create an issue for this.

@azeey
Copy link
Collaborator Author

azeey commented Nov 18, 2020


test/integration/nested_model.cc, line 628 at r20 (raw file):

Previously, azeey (Addisu Z. Taddese) wrote…

Okay, yeah, I'll go ahead and merge the PR and create an issue for this.

#420

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Should allow "drilling down" into nested model frames
4 participants