@@ -83,8 +83,14 @@ sdf::InterfaceModelPtr parseModel(toml::Value &_doc,
83
83
84
84
class CustomTomlParser
85
85
{
86
- public: CustomTomlParser(bool _supportsMergeInclude = true )
87
- : supportsMergeInclude(_supportsMergeInclude)
86
+ // / \brief Constructor
87
+ // / \param[in] _supportsMergeInclude Whether the parser supports merge include
88
+ // / \param[in] _overridePoseInParser Whether the parser should apply pose
89
+ // / overrides from //include/pose
90
+ public: CustomTomlParser(bool _supportsMergeInclude = true ,
91
+ bool _overridePoseInParser = true )
92
+ : supportsMergeInclude(_supportsMergeInclude),
93
+ overridePoseInParser (_overridePoseInParser)
88
94
{
89
95
}
90
96
@@ -104,7 +110,7 @@ class CustomTomlParser
104
110
param.Set (*_include.IsStatic ());
105
111
doc[" static" ] = {param};
106
112
}
107
- if (_include.IncludeRawPose ().has_value ())
113
+ if (this -> overridePoseInParser && _include.IncludeRawPose ().has_value ())
108
114
{
109
115
// if //include/static is set, override the value in the inluded model
110
116
sdf::Param poseParam (" pose" , " pose" , " " , false );
@@ -120,6 +126,7 @@ class CustomTomlParser
120
126
}
121
127
122
128
public: bool supportsMergeInclude;
129
+ public: bool overridePoseInParser{true };
123
130
};
124
131
125
132
bool endsWith (const std::string &_str, const std::string &_suffix)
@@ -552,16 +559,34 @@ TEST_F(InterfaceAPI, FrameSemantics)
552
559
const std::string testFile = sdf::testing::TestFile (
553
560
" sdf" , " include_with_interface_api_frame_semantics.sdf" );
554
561
this ->config .RegisterCustomModelParser (this ->customTomlParser );
555
- sdf::Root root;
556
- sdf::Errors errors = root.Load (testFile, config);
557
- EXPECT_TRUE (errors.empty ()) << errors;
562
+ {
563
+ sdf::Root root;
564
+ sdf::Errors errors = root.Load (testFile, config);
565
+ EXPECT_TRUE (errors.empty ()) << errors;
558
566
559
- const sdf::World *world = root.WorldByIndex (0 );
560
- ASSERT_NE (nullptr , world);
561
- EXPECT_EQ (1u , world->InterfaceModelCount ());
567
+ const sdf::World *world = root.WorldByIndex (0 );
568
+ ASSERT_NE (nullptr , world);
569
+ EXPECT_EQ (1u , world->InterfaceModelCount ());
562
570
563
- SCOPED_TRACE (" InterfaceAPI.FrameSemantics" );
564
- this ->CheckFrameSemantics (world);
571
+ SCOPED_TRACE (" InterfaceAPI.FrameSemantics" );
572
+ this ->CheckFrameSemantics (world);
573
+ }
574
+ {
575
+ // Check without //include/pose override applied in parser.
576
+ sdf::Root root;
577
+ sdf::ParserConfig newConfig = this ->config ;
578
+ CustomTomlParser parserWithoutPoseOverride (true , false );
579
+ newConfig.RegisterCustomModelParser (parserWithoutPoseOverride);
580
+ sdf::Errors errors = root.Load (testFile, newConfig);
581
+ EXPECT_TRUE (errors.empty ()) << errors;
582
+
583
+ const sdf::World *world = root.WorldByIndex (0 );
584
+ ASSERT_NE (nullptr , world);
585
+ EXPECT_EQ (1u , world->InterfaceModelCount ());
586
+
587
+ SCOPED_TRACE (" InterfaceAPI.FrameSemantics_NoPoseOverrideInParser" );
588
+ this ->CheckFrameSemantics (world);
589
+ }
565
590
}
566
591
567
592
// ///////////////////////////////////////////////
0 commit comments