| 56 | using CloudVector = std::vector<CloudPair>; |
| 57 | |
| 58 | bool |
| 59 | loopDetection (int end, const CloudVector &clouds, double dist, int &first, int &last) |
| 60 | { |
| 61 | static double min_dist = -1; |
| 62 | int state = 0; |
| 63 | |
| 64 | for (int i = end-1; i > 0; i--) |
| 65 | { |
| 66 | Eigen::Vector4f cstart, cend; |
| 67 | //TODO use pose of scan |
| 68 | pcl::compute3DCentroid (*(clouds[i].second), cstart); |
| 69 | pcl::compute3DCentroid (*(clouds[end].second), cend); |
| 70 | Eigen::Vector4f diff = cend - cstart; |
| 71 | |
| 72 | double norm = diff.norm (); |
| 73 | |
| 74 | //std::cout << "distance between " << i << " and " << end << " is " << norm << " state is " << state << std::endl; |
| 75 | |
| 76 | if (state == 0 && norm > dist) |
| 77 | { |
| 78 | state = 1; |
| 79 | //std::cout << "state 1" << std::endl; |
| 80 | } |
| 81 | if (state > 0 && norm < dist) |
| 82 | { |
| 83 | state = 2; |
| 84 | //std::cout << "loop detected between scan " << i << " (" << clouds[i].first << ") and scan " << end << " (" << clouds[end].first << ")" << std::endl; |
| 85 | if (min_dist < 0 || norm < min_dist) |
| 86 | { |
| 87 | min_dist = norm; |
| 88 | first = i; |
| 89 | last = end; |
| 90 | } |
| 91 | } |
| 92 | } |
| 93 | //std::cout << "min_dist: " << min_dist << " state: " << state << " first: " << first << " end: " << end << std::endl; |
| 94 | if (min_dist > 0 && (state < 2 || end == static_cast<int>(clouds.size ()) - 1)) //TODO |
| 95 | { |
| 96 | min_dist = -1; |
| 97 | return true; |
| 98 | } |
| 99 | return false; |
| 100 | } |
| 101 | |
| 102 | int |
| 103 | main (int argc, char **argv) |
no test coverage detected