-
Notifications
You must be signed in to change notification settings - Fork 100
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
Fix deeply nested merge-include for custom parsed files #1293
Conversation
Codecov Report
@@ Coverage Diff @@
## sdf13 #1293 +/- ##
==========================================
+ Coverage 87.60% 87.68% +0.07%
==========================================
Files 128 128
Lines 16823 16989 +166
==========================================
+ Hits 14737 14896 +159
- Misses 2086 2093 +7
|
34f71d7
to
ed0477f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just noting some -Wpedantic
complaints; I'm still reviewing
Signed-off-by: Addisu Z. Taddese <[email protected]>
This removes a check on the validity of a link pointer returned by a recursive call to Model::CanonicalLinkAndRelativeName because the pointer can be nullptr when the canonical link is an interface link. See gazebosim#544 Signed-off-by: Addisu Z. Taddese <[email protected]>
This is in preparation for the next change which adds model merging. Signed-off-by: Addisu Z. Taddese <[email protected]>
Signed-off-by: Addisu Z. Taddese <[email protected]>
Signed-off-by: Addisu Z. Taddese <[email protected]>
6786456
to
e852813
Compare
Errors frameLoadErrors = loadUniqueRepeated<Frame>(_sdf, "frame", | ||
this->dataPtr->frames); | ||
errors.insert(errors.end(), frameLoadErrors.begin(), frameLoadErrors.end()); | ||
|
||
// Check frames for name collisions and modify and warn if so. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not something new here, but I just noticed that this logic block always sets WARNING
and doesn't check if (sdfVersion < gz::math::SemanticVersion(1, 7))
and set DUPLICATE_NAME
for newer versions, like is done in Model.cc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Should we address it in a separate PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, that's fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
opened a draft PR in #1311
Signed-off-by: Addisu Z. Taddese <[email protected]>
Errors frameLoadErrors = loadUniqueRepeated<Frame>(_sdf, "frame", | ||
this->dataPtr->frames); | ||
errors.insert(errors.end(), frameLoadErrors.begin(), frameLoadErrors.end()); | ||
|
||
// Check frames for name collisions and modify and warn if so. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, that's fine
Signed-off-by: Addisu Z. Taddese <[email protected]>
🦟 Bug fix
Note: Since there are relatively large changes in
Model.cc
, I've tried to organize the commits in logical order. It might be easier to review by commit rather than the whole change at once.Summary
This addresses a bug where custom parsed models were not being processed if they happen to be nested two levels or more deep where one or more of those levels is also a merge-include. This was mainly because the
include
tags (which remain asinclude
tags when they point to a custom parsed file) of a merge-included child model were not moved/merged into the parent model. Currently, we only merge the elementslink
,model
,joint
,frame
,gripper
andplugin
:sdformat/src/parser.cc
Lines 368 to 372 in b363e0e
However simply fixing by including
include
in that list exposed another problem. When processing merge-included files, we currently create a throwawaysdf::Root
object, load the merge-included file as a standalone model and check that it's a valid model. However, if that model itself contains a custom-parsed model, the custom parser will end up being called during this validation step. Later on, when we create the finalsdf::Root
object, the custom parser would end up being called again. This would cause problems if the custom parser is storing some state about the models it processed, which is likely the case.The approach I've taken here is to treat the custom-parser case as a special case and assume the DOM API will be used. And instead of trying to expand any
include
tag inparser.cc
, we leave it as aninclude
tag and process it in theModel
orWorld
classes. This would ensure that the custom parser will only be called once./cc @EricCousineau-TRI
Checklist
codecheck
passed (See contributing)Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining
Signed-off-by
messages.