MCPcopy Create free account
hub / github.com/TUC-ProAut/libRSF / ReadYAMLOptions

Method ReadYAMLOptions

src/FactorGraphConfig.cpp:180–430  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

178 }
179
180 bool FactorGraphConfig::ReadYAMLOptions(const string YAMLFile)
181 {
182 /** check if file available */
183 if (FILE *File = fopen(YAMLFile.c_str(), "r"))
184 {
185 fclose(File);
186 }
187 else
188 {
189 PRINT_ERROR("There is no YAML file with the name ", YAMLFile);
190 return false;
191 }
192
193 /** read all files */
194 const YAML::Node YAMLComplete = YAML::LoadFile(YAMLFile);
195
196 /** config node holds the relevant configuration */
197 const YAML::Node YAMLConfig = YAMLComplete["config"];
198
199 /** solution */
200 string SolTypeString = YAMLConfig["solution"]["solver_mode"].as<std::string>();
201 if(!TranslateSafe(SolutionTypeDict, SolTypeString, Solution.Type))
202 {
203 PRINT_ERROR("Wrong solution type: ", SolTypeString);
204 return false;
205 }
206
207 switch (Solution.Type)
208 {
209 case SolutionType::Batch:
210 SolverConfig.minimizer_progress_to_stdout = false;
211
212 SolverConfig.max_num_iterations = YAMLConfig["solution"]["max_iterations"].as<double>();
213 SolverConfig.max_solver_time_in_seconds = YAMLConfig["solution"]["max_time"].as<double>();
214
215 Solution.EstimateCov = YAMLConfig["solution"]["estimate_cov"].as<bool>();
216 break;
217
218 case SolutionType::Smoother:
219 SolverConfig.minimizer_progress_to_stdout = false;
220
221 SolverConfig.max_num_iterations = YAMLConfig["solution"]["max_iterations"].as<double>();
222 SolverConfig.max_solver_time_in_seconds = YAMLConfig["solution"]["max_time"].as<double>();
223
224 Solution.EstimateCov = YAMLConfig["solution"]["estimate_cov"].as<bool>();
225 break;
226
227 case SolutionType::SmootherRT:
228 SolverConfig.minimizer_progress_to_stdout = false;
229
230 SolverConfig.max_num_iterations = YAMLConfig["solution"]["max_iterations"].as<double>();
231 SolverConfig.max_solver_time_in_seconds = YAMLConfig["solution"]["max_time"].as<double>();
232 Solution.WindowLength = YAMLConfig["solution"]["window_length"].as<double>();
233
234 Solution.EstimateCov = YAMLConfig["solution"]["estimate_cov"].as<bool>();
235 break;
236
237 case SolutionType::Window:

Callers

nothing calls this directly

Calls 1

TranslateSafeFunction · 0.85

Tested by

no test coverage detected