MIT-SPARK / TEASER-plusplus

A fast and robust point cloud registration library
MIT License
1.81k stars 344 forks source link

[QUESTION] potential ambiguity of sort in estimate scale #159

Open democheng opened 1 year ago

democheng commented 1 year ago

Have you read the documentation?

Post your theoretical questions / usage questions here.

I found "void teaser::ScalarTLSEstimator::estimate" at line 21 in registration.cc is very similar to Marzullo's algorithm and Brooks–Iyengar algorithm

as described in Marzullo's algorithm

Sort the table by the offset. (If two tuples with the same offset but opposite types exist, indicating that one interval ends just as another begins, then a method of deciding which comes first is necessary. Such an occurrence can be considered an overlap with no duration, which can be found by the algorithm by putting type −1 before type +1. If such pathological overlaps are considered objectionable they can be avoided by putting type +1 before −1 in this case.)

To solve the potential ambiguity of sort, I rewrite the sort function like this:

  // ascending order
  std::sort(h.begin(), h.end(), [](std::pair<double, int> a, std::pair<double, int> b) { 
    if (a.first != b.first) {
      return a.first < b.first;
    } else {
      return a.second < b.second;
    }
     });