@@ -243,6 +243,54 @@ TEST(NestedModel, State)
243243 ignition::math::Pose3d (0 , 0 , 0 , 0 , 0 , 0 ));
244244}
245245
246+ // //////////////////////////////////////
247+ // Test parsing a include element that has a pose element and includes a
248+ // submodel
249+ TEST (NestedModel, IncludeFlatteningNames)
250+ {
251+ const std::string MODEL_PATH =
252+ sdf::filesystem::append (PROJECT_SOURCE_PATH, " test" , " integration" ,
253+ " model" , " nested_names_test" );
254+
255+ std::ostringstream stream;
256+ std::string version = SDF_VERSION;
257+ stream
258+ << " <sdf version='" << version << " '>"
259+ << " <model name='top_level_model'>"
260+ << " <include>"
261+ << " <uri>" + MODEL_PATH +" </uri>"
262+ << " </include>"
263+ << " </model>"
264+ << " </sdf>" ;
265+
266+ sdf::SDFPtr sdfParsed (new sdf::SDF ());
267+ sdf::init (sdfParsed);
268+ ASSERT_TRUE (sdf::readString (stream.str (), sdfParsed));
269+
270+ sdf::ElementPtr modelElem = sdfParsed->Root ()->GetElement (" model" );
271+ EXPECT_EQ (modelElem->Get <std::string>(" name" ), " top_level_model" );
272+
273+ sdf::ElementPtr linkElem = modelElem->GetElement (" link" );
274+ EXPECT_EQ (linkElem->Get <std::string>(" name" ), " main_model_prefix::frame" );
275+
276+ sdf::ElementPtr jointElem = modelElem->GetElement (" joint" );
277+ EXPECT_EQ (jointElem->Get <std::string>(" name" ), " main_model_prefix::joint1" );
278+ EXPECT_EQ (jointElem->Get <std::string>(" parent" ),
279+ " main_model_prefix::subnested_model" );
280+ EXPECT_EQ (jointElem->Get <std::string>(" child" ),
281+ " main_model_prefix::subnested_model::link1" ) <<
282+ " Flattening logic for nested models failed (check parser.cc)" ;
283+
284+ sdf::ElementPtr joint2Elem = jointElem->GetNextElement (" joint" );
285+ EXPECT_EQ (joint2Elem->Get <std::string>(" name" ), " main_model_prefix::joint2" );
286+ EXPECT_EQ (joint2Elem->Get <std::string>(" parent" ),
287+ " main_model_prefix::subnested_model::link1" ) <<
288+ " Flattening logic for nested models failed (check parser.cc)" ;
289+ EXPECT_EQ (joint2Elem->Get <std::string>(" child" ),
290+ " main_model_prefix::joint1" ) <<
291+ " Flattening logic for nested models failed (check parser.cc)" ;
292+ }
293+
246294// //////////////////////////////////////
247295// Test parsing models with joints nested via <include>
248296// Confirm that joint axis rotation is handled differently for 1.4 and 1.5+
0 commit comments