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

Backport #399 to sdf9: Prefix nested model names when flattening #424

Merged
merged 1 commit into from
Nov 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1285,6 +1285,7 @@ void addNestedModel(ElementPtr _sdf, ElementPtr _includeSDF, Errors &_errors)
while (elem)
{
if ((elem->GetName() == "link") ||
(elem->GetName() == "model") ||
(elem->GetName() == "joint") ||
(elem->GetName() == "frame"))
{
Expand All @@ -1293,7 +1294,7 @@ void addNestedModel(ElementPtr _sdf, ElementPtr _includeSDF, Errors &_errors)
replace[elemName] = newName;
}

if ((elem->GetName() == "link"))
if ((elem->GetName() == "link") || (elem->GetName() == "model"))
{
// Add a pose element even if the element doesn't originally have one
auto elemPose = elem->GetElement("pose");
Expand Down
6 changes: 6 additions & 0 deletions test/integration/model/test_model_with_frames/model.sdf
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,11 @@
<parent>L3</parent>
<child>L4</child>
</joint>
<model name="M2">
<pose relative_to="F1">1 0 0 0 0 0</pose>
<link name="L5">
<pose>1 0 0 0 0 0</pose>
</link>
</model>
</model>
</sdf>
6 changes: 6 additions & 0 deletions test/integration/nested_model_with_frames_expected.sdf
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@
<parent>M1::L3</parent>
<child>M1::L4</child>
</joint>
<model name='M1::M2'>
<pose relative_to='M1::F1'>1 0 0 0 -0 0</pose>
<link name='L5'>
<pose>1 0 0 0 -0 0</pose>
</link>
</model>
</model>
</world>
</sdf>
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@
<parent>M1::test_model_with_frames::L3</parent>
<child>M1::test_model_with_frames::L4</child>
</joint>
<model name='M1::test_model_with_frames::M2'>
<pose relative_to='M1::test_model_with_frames::F1'>1 0 0 0 -0 0</pose>
<link name='L5'>
<pose>1 0 0 0 -0 0</pose>
</link>
</model>
</model>
</world>
</sdf>