rpng / open_vins

An open source platform for visual-inertial navigation research.
https://docs.openvins.com
GNU General Public License v3.0
2.16k stars 636 forks source link

Erase lost features from marg points, why writing like this? #375

Closed WZG3661 closed 1 year ago

WZG3661 commented 1 year ago
// We also need to make sure that the max tracks does not contain any lost features
// This could happen if the feature was lost in the last frame, but has a measurement at the marg timestep
it1 = feats_lost.begin();
while (it1 != feats_lost.end()) {
  if (std::find(feats_marg.begin(), feats_marg.end(), (*it1)) != feats_marg.end()) {
    // PRINT_WARNING(YELLOW "FOUND FEATURE THAT WAS IN BOTH feats_lost and feats_marg!!!!!!\n" RESET);
    it1 = feats_lost.erase(it1);
  } else {
    it1++;
  }
}

If you want to erase lost feauters from marg points, why not writing like:

it1 = feats_marg.begin();
while (it1 != feats_marg.end()) {
  if (std::find(feats_lost.begin(), feats_lost.end(), (*it1)) != feats_lost.end()) {
    it1 = feats_marg.erase(it1);
  } else {
    it1++;
  }
}
WZG3661 commented 1 year ago

In my dataset, it makes a little different, but I can't which is better

goldbattle commented 1 year ago

This shouldn't make any difference. We only insert SLAM features which have reached max tracks, so the feature shouldn't be used in either case. I do think the second you have posted would make clearer sense to someone reading through the code though..