From 9b0195bc499484340348966414eb0ea5ea8b98be Mon Sep 17 00:00:00 2001 From: Steve Peters Date: Thu, 29 Oct 2020 23:29:31 -0700 Subject: [PATCH] Prefix nested model names when flattening (#399) Currently the addNestedModel function in parser.cc prefixes link, joint, and frame names with the flattened model name delimited by "::". This applies the same prefix to the names of nested models within the flattened model as well. Signed-off-by: Steve Peters --- src/parser.cc | 3 ++- test/integration/model/test_model_with_frames/model.sdf | 6 ++++++ test/integration/nested_model_with_frames_expected.sdf | 6 ++++++ .../two_level_nested_model_with_frames_expected.sdf | 6 ++++++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/parser.cc b/src/parser.cc index 5fde25f7d..a92e44d8b 100644 --- a/src/parser.cc +++ b/src/parser.cc @@ -1322,6 +1322,7 @@ void addNestedModel(ElementPtr _sdf, ElementPtr _includeSDF, Errors &_errors) while (elem) { if ((elem->GetName() == "link") || + (elem->GetName() == "model") || (elem->GetName() == "joint") || (elem->GetName() == "frame")) { @@ -1330,7 +1331,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"); diff --git a/test/integration/model/test_model_with_frames/model.sdf b/test/integration/model/test_model_with_frames/model.sdf index f085ec4b8..b34e0375c 100644 --- a/test/integration/model/test_model_with_frames/model.sdf +++ b/test/integration/model/test_model_with_frames/model.sdf @@ -59,5 +59,11 @@ L3 L4 + + 1 0 0 0 0 0 + + 1 0 0 0 0 0 + + diff --git a/test/integration/nested_model_with_frames_expected.sdf b/test/integration/nested_model_with_frames_expected.sdf index 6e3f1dcbe..2385f000f 100644 --- a/test/integration/nested_model_with_frames_expected.sdf +++ b/test/integration/nested_model_with_frames_expected.sdf @@ -63,6 +63,12 @@ M1::L3 M1::L4 + + 1 0 0 0 -0 0 + + 1 0 0 0 -0 0 + + diff --git a/test/integration/two_level_nested_model_with_frames_expected.sdf b/test/integration/two_level_nested_model_with_frames_expected.sdf index f96fae7ba..807fa6d6c 100644 --- a/test/integration/two_level_nested_model_with_frames_expected.sdf +++ b/test/integration/two_level_nested_model_with_frames_expected.sdf @@ -66,6 +66,12 @@ M1::test_model_with_frames::L3 M1::test_model_with_frames::L4 + + 1 0 0 0 -0 0 + + 1 0 0 0 -0 0 + +