@@ -152,6 +152,85 @@ OdometryOpenVINS::OdometryOpenVINS(const ParametersMap & parameters) :
152152 params_->init_options .sigma_wb = params_->imu_noises .sigma_wb ;
153153 params_->init_options .sigma_pix = params_->slam_options .sigma_pix ;
154154 params_->init_options .gravity_mag = params_->gravity_mag ;
155+
156+ if (parameters.find (Parameters::kOdomOpenVINSConfigPath ()) != parameters.end ())
157+ {
158+ // Load the config: will override all parameters above!
159+ std::string configPath = parameters.at (Parameters::kOdomOpenVINSConfigPath ());
160+ if (!configPath.empty ())
161+ {
162+ if (UFile::exists (configPath))
163+ {
164+ UWARN (" OpenVINS config file is provided (%s=\" %s\" ), reading it. The parameters from the config file will overwrite OdomOpenVINS/*** parameters." ,
165+ Parameters::kOdomOpenVINSConfigPath ().c_str (), configPath.c_str ());
166+ auto parser = std::make_shared<ov_core::YamlParser>(configPath);
167+
168+ // The sequence of loading is based on VioManagerOptions::print_and_load()
169+ // We removed all parts about intrinsics/extrinsics, which will be loaded later
170+ // when we receive the data (which should already include intrinsics and extrinsics).
171+
172+ params_->state_options .print (parser);
173+
174+ params_->init_options .print_and_load_initializer (parser);
175+ params_->init_options .print_and_load_noise (parser);
176+ parser->parse_config (" gravity_mag" , params_->init_options .gravity_mag );
177+ parser->parse_config (" max_cameras" , params_->init_options .num_cameras );
178+ parser->parse_config (" use_stereo" , params_->init_options .use_stereo );
179+ parser->parse_config (" downsample_cameras" , params_->init_options .downsample_cameras );
180+
181+ parser->parse_config (" dt_slam_delay" , params_->dt_slam_delay );
182+ parser->parse_config (" try_zupt" , params_->try_zupt );
183+ parser->parse_config (" zupt_max_velocity" ,params_-> zupt_max_velocity);
184+ parser->parse_config (" zupt_noise_multiplier" , params_->zupt_noise_multiplier );
185+ parser->parse_config (" zupt_max_disparity" , params_->zupt_max_disparity );
186+ parser->parse_config (" zupt_only_at_beginning" , params_->zupt_only_at_beginning );
187+ parser->parse_config (" record_timing_information" , params_->record_timing_information );
188+ parser->parse_config (" record_timing_filepath" , params_->record_timing_filepath );
189+
190+ params_->print_and_load_trackers (parser);
191+ params_->print_and_load_noise (parser);
192+
193+ if (params_->state_options .num_cameras > 2 )
194+ {
195+ UFATAL (" OpenVINS integration in RTAB-Map doesn't support more than 2 cameras (num_cameras=%d)." , params_->state_options .num_cameras );
196+ }
197+
198+ parser->parse_config (" gravity_mag" , params_->gravity_mag );
199+ parser->parse_config (" use_mask" , params_->use_mask );
200+ params_->masks .clear ();
201+ if (params_->use_mask ) {
202+ for (int i = 0 ; i < params_->state_options .num_cameras ; i++) {
203+ std::string mask_path;
204+ std::string mask_node = " mask" + std::to_string (i);
205+ parser->parse_config (mask_node, mask_path);
206+ std::string total_mask_path = parser->get_config_folder () + mask_path;
207+ if (!boost::filesystem::exists (total_mask_path)) {
208+ PRINT_ERROR (RED " VioManager(): invalid mask path:\n " RESET );
209+ PRINT_ERROR (RED " \t - mask%d - %s\n " RESET , i, total_mask_path.c_str ());
210+ std::exit (EXIT_FAILURE );
211+ }
212+ params_->masks .emplace (i, cv::imread (total_mask_path, cv::IMREAD_GRAYSCALE ));
213+ }
214+ }
215+
216+ if (!parser->successful ()) {
217+ UWARN (" Not all expected OpenVINS parameters were read successfully "
218+ " from \" %s\" . Values from RTAB-Map's OpenOpenVINS/* parameters "
219+ " will be used instead for the missing ones." ,
220+ configPath.c_str ());
221+ }
222+ else {
223+ UINFO (" OpenVINS config file(%s=\" %s\" ) read." ,
224+ Parameters::kOdomOpenVINSConfigPath ().c_str (), configPath.c_str ());
225+ }
226+ }
227+ else
228+ {
229+ UERROR (" OpenVINS config file is provided (%s=\" %s\" ) but it doesn't exist!" ,
230+ Parameters::kOdomOpenVINSConfigPath ().c_str (), configPath.c_str ());
231+ }
232+ }
233+ }
155234#endif
156235}
157236
0 commit comments