50 void CLandmarksMap::TMapDefinition::loadFromConfigFile_map_specific(
56 sectionNamePrefix +
string(
"_creationOpts");
57 this->initialBeacons.clear();
58 const unsigned int nBeacons =
source.read_int(sSectCreation,
"nBeacons", 0);
59 for (
unsigned int q = 1;
q <= nBeacons;
q++)
63 source.read_int(sSectCreation,
format(
"beacon_%03u_ID",
q), 0);
66 source.read_float(sSectCreation,
format(
"beacon_%03u_x",
q), 0);
68 source.read_float(sSectCreation,
format(
"beacon_%03u_y",
q), 0);
70 source.read_float(sSectCreation,
format(
"beacon_%03u_z",
q), 0);
72 this->initialBeacons.push_back(newPair);
75 insertionOpts.loadFromConfigFile(
76 source, sectionNamePrefix +
string(
"_insertOpts"));
77 likelihoodOpts.loadFromConfigFile(
78 source, sectionNamePrefix +
string(
"_likelihoodOpts"));
81 void CLandmarksMap::TMapDefinition::dumpToTextStream_map_specific(
82 std::ostream& out)
const
85 "number of initial beacons = %u\n",
86 (
int)initialBeacons.size());
90 "--------------------------------------------------------\n");
92 p != initialBeacons.end(); ++
p)
94 " %03u (%8.03f,%8.03f,%8.03f)\n",
p->second,
95 p->first.x,
p->first.y,
p->first.z);
97 this->insertionOpts.dumpToTextStream(out);
98 this->likelihoodOpts.dumpToTextStream(out);
126 obj->landmarks.push_back(lm);
144 CLandmarksMap::_mEDD;
146 bool CLandmarksMap::_maxIDUpdated =
false;
150 CLandmarksMap::CLandmarksMap()
209 for (i = 0; i <
n; i++)
295 unsigned int sensedID = it->beaconID;
302 (lm_it->ID == sensedID) &&
303 (!std::isnan(it->sensedDistance)))
305 lm_it->getPose(beaconPDF);
306 beacon3D = beaconPDF.
mean;
309 point3D = robotPose3D + it->sensorLocationOnRobot;
311 const float expectedRange = point3D.
distanceTo(beacon3D);
312 float sensedDist = it->sensedDistance;
313 if (sensedDist < 0) sensedDist = 0;
321 square((expectedRange - sensedDist) / sensorStd));
357 CMatrixD dij(1, 6), Cij(6, 6), Cij_1;
358 dij(0, 0) = o->
pose.
mean.
x() - sensorPose3D.
x();
359 dij(0, 1) = o->
pose.
mean.
y() - sensorPose3D.
y();
360 dij(0, 2) = o->
pose.
mean.z() - sensorPose3D.z();
369 double distMahaFlik2 = dij.multiply_HCHt_scalar(Cij_1);
389 double earth_radius = 6378137;
479 robotPose2D =
CPose2D(*robotPose);
480 robotPose3D = (*robotPose);
596 float maxDistForCorrespondence,
float maxAngularDistForCorrespondence,
598 float& correspondencesRatio,
float* sumSqrDist,
bool onlyKeepTheClosest,
599 bool onlyUniqueRobust)
const
611 CPose3D otherMapPose3D(otherMapPose);
613 correspondencesRatio = 0;
619 std::vector<bool> otherCorrespondences;
626 otherMap2, correspondences, correspondencesRatio, otherCorrespondences);
666 for (sift = siftList.
begin(); sift != siftList.
end(); sift++)
680 landmark3DPositionPDF.
mean *= d;
686 D(0, 0) =
square(0.5 * d);
699 Normal *= -1 / Normal.
norm();
735 fExt.options = feat_options;
753 leftSiftList, rightSiftList, matchesList, matchingOptions);
757 std::cerr <<
"Warning: insertionOptions.PLOT_IMAGES has no effect "
758 "since MRPT 0.9.1\n";
776 stereoParams.
minZ = 0.0f;
779 size_t numM = matchesList.size();
787 (*ii).seenTimesCount = 1;
791 "%u (out of %u) corrs!\n",
static_cast<unsigned>(
landmarks.
size()),
792 static_cast<unsigned>(numM));
813 double R11 = HM.get_unsafe(0, 0);
814 double R12 = HM.get_unsafe(0, 1);
815 double R13 = HM.get_unsafe(0, 2);
816 double R21 = HM.get_unsafe(1, 0);
817 double R22 = HM.get_unsafe(1, 1);
818 double R23 = HM.get_unsafe(1, 2);
819 double R31 = HM.get_unsafe(2, 0);
820 double R32 = HM.get_unsafe(2, 1);
821 double R33 = HM.get_unsafe(2, 2);
823 double c11, c22, c33, c12, c13, c23;
833 float C11 = lm->pose_cov_11;
834 float C22 = lm->pose_cov_22;
835 float C33 = lm->pose_cov_33;
836 float C12 = lm->pose_cov_12;
837 float C13 = lm->pose_cov_13;
838 float C23 = lm->pose_cov_23;
841 c11 = R11 * (C11 * R11 + C12 * R12 + C13 * R13) +
842 R12 * (C12 * R11 + C22 * R12 + C23 * R13) +
843 R13 * (C13 * R11 + C23 * R12 + C33 * R13);
844 c12 = (C11 * R11 + C12 * R12 + C13 * R13) * R21 +
845 (C12 * R11 + C22 * R12 + C23 * R13) * R22 +
846 (C13 * R11 + C23 * R12 + C33 * R13) * R23;
847 c13 = (C11 * R11 + C12 * R12 + C13 * R13) * R31 +
848 (C12 * R11 + C22 * R12 + C23 * R13) * R32 +
849 (C13 * R11 + C23 * R12 + C33 * R13) * R33;
850 c22 = R21 * (C11 * R21 + C12 * R22 + C13 * R23) +
851 R22 * (C12 * R21 + C22 * R22 + C23 * R23) +
852 R23 * (C13 * R21 + C23 * R22 + C33 * R23);
853 c23 = (C11 * R21 + C12 * R22 + C13 * R23) * R31 +
854 (C12 * R21 + C22 * R22 + C23 * R23) * R32 +
855 (C13 * R21 + C23 * R22 + C33 * R23) * R33;
856 c33 = R31 * (C11 * R31 + C12 * R32 + C13 * R33) +
857 R32 * (C12 * R31 + C22 * R32 + C23 * R33) +
858 R33 * (C13 * R31 + C23 * R32 + C33 * R33);
861 lm->pose_cov_11 = c11;
862 lm->pose_cov_22 = c22;
863 lm->pose_cov_33 = c33;
864 lm->pose_cov_12 = c12;
865 lm->pose_cov_13 = c13;
866 lm->pose_cov_23 = c23;
870 float Nx = lm->normal.x;
871 float Ny = lm->normal.y;
872 float Nz = lm->normal.z;
874 lm->normal.x = Nx * R11 + Ny * R12 + Nz * R13;
875 lm->normal.y = Nx * R21 + Ny * R22 + Nz * R23;
876 lm->normal.z = Nx * R31 + Ny * R32 + Nz * R33;
896 double R11 = HM.get_unsafe(0, 0);
897 double R12 = HM.get_unsafe(0, 1);
898 double R13 = HM.get_unsafe(0, 2);
899 double R21 = HM.get_unsafe(1, 0);
900 double R22 = HM.get_unsafe(1, 1);
901 double R23 = HM.get_unsafe(1, 2);
902 double R31 = HM.get_unsafe(2, 0);
903 double R32 = HM.get_unsafe(2, 1);
904 double R33 = HM.get_unsafe(2, 2);
906 double c11, c22, c33, c12, c13, c23;
920 float C11 = lm->pose_cov_11;
921 float C22 = lm->pose_cov_22;
922 float C33 = lm->pose_cov_33;
923 float C12 = lm->pose_cov_12;
924 float C13 = lm->pose_cov_13;
925 float C23 = lm->pose_cov_23;
928 c11 = R11 * (C11 * R11 + C12 * R12 + C13 * R13) +
929 R12 * (C12 * R11 + C22 * R12 + C23 * R13) +
930 R13 * (C13 * R11 + C23 * R12 + C33 * R13);
931 c12 = (C11 * R11 + C12 * R12 + C13 * R13) * R21 +
932 (C12 * R11 + C22 * R12 + C23 * R13) * R22 +
933 (C13 * R11 + C23 * R12 + C33 * R13) * R23;
934 c13 = (C11 * R11 + C12 * R12 + C13 * R13) * R31 +
935 (C12 * R11 + C22 * R12 + C23 * R13) * R32 +
936 (C13 * R11 + C23 * R12 + C33 * R13) * R33;
937 c22 = R21 * (C11 * R21 + C12 * R22 + C13 * R23) +
938 R22 * (C12 * R21 + C22 * R22 + C23 * R23) +
939 R23 * (C13 * R21 + C23 * R22 + C33 * R23);
940 c23 = (C11 * R21 + C12 * R22 + C13 * R23) * R31 +
941 (C12 * R21 + C22 * R22 + C23 * R23) * R32 +
942 (C13 * R21 + C23 * R22 + C33 * R23) * R33;
943 c33 = R31 * (C11 * R31 + C12 * R32 + C13 * R33) +
944 R32 * (C12 * R31 + C22 * R32 + C23 * R33) +
945 R33 * (C13 * R31 + C23 * R32 + C33 * R33);
957 float Nx = lm->normal.x;
958 float Ny = lm->normal.y;
959 float Nz = lm->normal.z;
961 newLandmark.
normal.
x = Nx * R11 + Ny * R12 + Nz * R13;
962 newLandmark.
normal.
y = Nx * R21 + Ny * R22 + Nz * R23;
963 newLandmark.
normal.
z = Nx * R31 + Ny * R32 + Nz * R33;
965 newLandmark.
ID = lm->ID;
967 newLandmark.
features = lm->features;
985 std::vector<bool> otherCorrs(other.
size(),
false);
993 unsigned int nRemoved = 0;
995 if (!justInsertAllOfThem)
1003 for (corrIt = corrs.begin(); corrIt != corrs.end(); corrIt++)
1031 for (i = 0; i <
n; i++)
1044 if (!justInsertAllOfThem)
1050 for (i =
n - 1; i >= 0; i--)
1072 "[CLandmarksMap::fuseWith] %u fused/ %u new/ %u removed -> %u "
1074 static_cast<unsigned int>(corrs.size()),
1075 static_cast<unsigned int>(other.
size() - corrs.size()),
1076 static_cast<unsigned int>(nRemoved),
1080 f,
"%u\t%u\t%u\t%u\n",
static_cast<unsigned int>(corrs.size()),
1081 static_cast<unsigned int>(other.
size() - corrs.size()),
1082 static_cast<unsigned int>(nRemoved),
1096 std::vector<bool>& otherCorrespondences)
const
1101 unsigned int nThis, nOther;
1104 unsigned int i,
n, j, k;
1106 double lik_dist, lik_desc, lik, maxLik;
1110 std::vector<bool> thisLandmarkAssigned;
1111 double K_desc = 0.0;
1112 double K_dist = 0.0;
1122 thisLandmarkAssigned.resize(nThis,
false);
1125 correspondences.clear();
1126 otherCorrespondences.clear();
1127 otherCorrespondences.resize(nOther,
false);
1128 correspondencesRatio = 0;
1150 otherIt != anotherMap->
landmarks.
end(); otherIt++, k++)
1153 otherIt->getPose(pointPDF_k);
1155 if (otherIt->getType() ==
featSIFT)
1177 if (thisIt->getType() ==
featSIFT &&
1178 thisIt->features.size() ==
1179 otherIt->features.size() &&
1180 !thisIt->features.empty() && thisIt->features[0] &&
1181 otherIt->features[0] &&
1182 thisIt->features[0]->descriptors.SIFT.size() ==
1183 otherIt->features[0]->descriptors.SIFT.size())
1189 thisIt->getPose(pointPDF_j);
1196 double distMahaFlik2;
1204 pointPDF_k.
mean.z() - pointPDF_j.
mean.z();
1211 distMahaFlik2 = dij.multiply_HCHt_scalar(
1215 exp(K_dist * distMahaFlik2);
1220 if (lik_dist > 1e-2)
1233 mPair(thisIt->ID, otherIt->ID);
1237 n = otherIt->features[0]
1238 ->descriptors.SIFT.size();
1240 for (i = 0; i <
n; i++)
1242 otherIt->features[0]
1243 ->descriptors.SIFT[i] -
1245 ->descriptors.SIFT[i]);
1263 lik_desc = exp(K_desc * desc);
1274 lik = lik_dist * lik_desc;
1304 if (!thisLandmarkAssigned[maxIdx])
1306 thisLandmarkAssigned[maxIdx] =
true;
1309 otherCorrespondences[k] =
true;
1324 correspondences.push_back(match);
1333 correspondencesRatio =
1334 correspondences.size() /
static_cast<float>(nOther);
1354 ->descriptors.SIFT.size();
1356 otherIt != anotherMap->
landmarks.
end(); otherIt++, k++)
1359 unsigned int mEDDidx = 0;
1365 for (i = 0; i < dLen; i++)
1367 otherIt->features[0]->descriptors.SIFT[i] -
1368 thisIt->features[0]->descriptors.SIFT[i]);
1382 if (!thisLandmarkAssigned[mEDDidx])
1386 thisLandmarkAssigned[mEDDidx] =
true;
1389 otherCorrespondences[k] =
true;
1391 otherIt->getPose(pointPDF_k);
1392 thisIt->getPose(pointPDF_j);
1407 correspondences.push_back(match);
1415 correspondencesRatio =
1416 correspondences.size() /
static_cast<float>(nOther);
1432 FILE* f =
os::fopen(file.c_str(),
"wt");
1433 if (!f)
return false;
1446 f,
"%10f %10f %10f %4i %4u %10f", it->pose_mean.x, it->pose_mean.y,
1447 it->pose_mean.z,
static_cast<int>(it->getType()),
1452 it->timestampLastSeen));
1456 ASSERT_(!it->features.empty() && it->features[0]);
1457 for (
unsigned int i = 0;
1458 i < it->features[0]->descriptors.SIFT.size(); i++)
1459 os::fprintf(f,
" %u ", it->features[0]->descriptors.SIFT[i]);
1477 std::string file,
const char* style,
float confInterval)
const
1479 FILE* f =
os::fopen(file.c_str(),
"wt");
1480 if (!f)
return false;
1484 f,
"%%-------------------------------------------------------\n");
1485 os::fprintf(f,
"%% File automatically generated using the MRPT method:\n");
1486 os::fprintf(f,
"%% 'CLandmarksMap::saveToMATLABScript3D'\n");
1490 f,
"%% Jose Luis Blanco Claraco, University of Malaga @ 2006\n");
1493 f,
"%%-------------------------------------------------------\n\n");
1502 f,
"m=[%.4f %.4f %.4f];", it->pose_mean.x, it->pose_mean.y,
1505 f,
"c=[%.8f %.8f %.8f;%.8f %.8f %.8f;%.8f %.8f %.8f]; ",
1506 it->pose_cov_11, it->pose_cov_12, it->pose_cov_13, it->pose_cov_12,
1507 it->pose_cov_22, it->pose_cov_23, it->pose_cov_13, it->pose_cov_23,
1512 "error_ellipse(c,m,'conf',%f,'style','%s','numPointsEllipse',10);"
1514 confInterval, style);
1517 os::fprintf(f,
"axis equal;grid on;xlabel('x'); ylabel('y'); zlabel('z');");
1528 std::string file,
const char* style,
float stdCount)
1530 FILE* f =
os::fopen(file.c_str(),
"wt");
1531 if (!f)
return false;
1533 const int ELLIPSE_POINTS = 30;
1534 std::vector<float> X, Y, COS, SIN;
1539 X.resize(ELLIPSE_POINTS);
1540 Y.resize(ELLIPSE_POINTS);
1541 COS.resize(ELLIPSE_POINTS);
1542 SIN.resize(ELLIPSE_POINTS);
1545 for (Cos = COS.begin(), Sin = SIN.begin(), ang = 0; Cos != COS.end();
1546 Cos++, Sin++, ang += (
M_2PI / (ELLIPSE_POINTS - 1)))
1554 f,
"%%-------------------------------------------------------\n");
1555 os::fprintf(f,
"%% File automatically generated using the MRPT method:\n");
1556 os::fprintf(f,
"%% 'CLandmarksMap::saveToMATLABScript2D'\n");
1560 f,
"%% Jose Luis Blanco Claraco, University of Malaga @ 2006\n");
1563 f,
"%%-------------------------------------------------------\n\n");
1572 cov(0, 0) = it->pose_cov_11;
1573 cov(1, 1) = it->pose_cov_22;
1574 cov(0, 1) =
cov(1, 0) = it->pose_cov_12;
1576 cov.eigenVectors(eigVec, eigVal);
1577 eigVal = eigVal.array().sqrt().matrix();
1578 M = eigVal * eigVec.transpose();
1582 for (
x = X.begin(),
y = Y.begin(), Cos = COS.begin(), Sin = SIN.begin();
1583 x != X.end();
x++,
y++, Cos++, Sin++)
1587 stdCount * (*Cos * M(0, 0) + *Sin * M(1, 0)));
1590 stdCount * (*Cos * M(0, 1) + *Sin * M(1, 1)));
1596 for (
x = X.begin();
x != X.end();
x++)
1602 for (
y = Y.begin();
y != Y.end();
y++)
1623 unsigned int downSampleFactor)
1627 double J11, J12, J21, J22;
1638 sensorGlobalPose = *robotPose + obs.
sensorPose;
1653 double var_d =
square(0.005);
1654 double var_th =
square(dTh / 10.0);
1657 for (i = 0; i <
n; i += downSampleFactor, Th += downSampleFactor * dTh)
1676 newLandmark.
features[0]->orientation = Th;
1677 newLandmark.
features[0]->scale = d;
1695 newLandmark.
pose_cov_11 = (J11 * J11 * var_th + J12 * J12 * var_d);
1696 newLandmark.
pose_cov_12 = (J11 * J21 * var_th + J12 * J22 * var_d);
1697 newLandmark.
pose_cov_22 = (J21 * J21 * var_th + J22 * J22 * var_d);
1735 double nFoundCorrs = 0;
1736 std::vector<int32_t>* corrs;
1737 unsigned int cx, cy, cx_1, cx_2, cy_1, cy_2;
1746 for (itOther =
s->landmarks.begin(); itOther !=
s->landmarks.end();
1749 itOther->getPose(poseOther);
1751 cx = cy = grid->
y2idx(itOther->pose_mean.y);
1753 cx_1 = max(0, grid->
x2idx(itOther->pose_mean.x - 0.10f));
1756 grid->
x2idx(itOther->pose_mean.x + 0.10f));
1757 cy_1 = max(0, grid->
y2idx(itOther->pose_mean.y - 0.10f));
1760 grid->
y2idx(itOther->pose_mean.y + 0.10f));
1771 for (cx = cx_1; cx <= cx_2; cx++)
1772 for (cy = cy_1; cy <= cy_2; cy++)
1776 if (!corrs->empty())
1778 it != corrs->end(); ++it)
1786 if (fabs(lm->
pose_mean.
x - itOther->pose_mean.x) >
1788 fabs(lm->
pose_mean.
y - itOther->pose_mean.y) >
1805 PrNoCorr *= 1 - corr;
1812 nFoundCorrs += 1 - PrNoCorr;
1843 lik *= 1 - PrNoCorr;
1847 lik = nFoundCorrs /
static_cast<double>(
s->size());
1864 m_grid(-10.0f, 10.0f, -10.0f, 10.f, 0.20f),
1865 m_largestDistanceFromOrigin(),
1866 m_largestDistanceFromOriginIsUpdated(false)
1872 m_landmarks.clear();
1877 m_largestDistanceFromOriginIsUpdated =
false;
1883 std::vector<int32_t> dummyEmpty;
1889 max(m_grid.getYMax(), l.
pose_mean.
y + 0.1), dummyEmpty);
1891 m_landmarks.push_back(l);
1896 cell->push_back(m_landmarks.size() - 1);
1898 m_largestDistanceFromOriginIsUpdated =
false;
1903 return &m_landmarks[indx];
1907 unsigned int indx)
const
1909 return &m_landmarks[indx];
1914 std::vector<int32_t>* cell = m_grid.cellByPos(
1915 m_landmarks[indx].pose_mean.x, m_landmarks[indx].pose_mean.y);
1918 for (it = cell->begin(); it != cell->end(); it++)
1920 if (*it ==
static_cast<int>(indx))
1927 m_largestDistanceFromOriginIsUpdated =
false;
1932 m_landmarks.erase(m_landmarks.begin() + indx);
1933 m_largestDistanceFromOriginIsUpdated =
false;
1938 std::vector<int32_t> dummyEmpty;
1942 min(m_grid.getXMin(), m_landmarks[indx].pose_mean.x),
1943 max(m_grid.getXMax(), m_landmarks[indx].pose_mean.x),
1944 min(m_grid.getYMin(), m_landmarks[indx].pose_mean.y),
1945 max(m_grid.getYMax(), m_landmarks[indx].pose_mean.y), dummyEmpty);
1948 std::vector<int32_t>* cell = m_grid.cellByPos(
1949 m_landmarks[indx].pose_mean.x, m_landmarks[indx].pose_mean.y);
1950 cell->push_back(indx);
1951 m_largestDistanceFromOriginIsUpdated =
false;
1960 double min_x = -10.0, max_x = 10.0;
1961 double min_y = -10.0, max_y = 10.0;
1962 std::vector<int32_t> dummyEmpty;
1968 for (idx = 0, it = m_landmarks.begin(); it != m_landmarks.end();
1971 min_x =
min(min_x, it->pose_mean.x);
1972 max_x = max(max_x, it->pose_mean.x);
1973 min_y =
min(min_y, it->pose_mean.y);
1974 max_y = max(max_y, it->pose_mean.y);
1976 m_grid.resize(min_x, max_x, min_y, max_y, dummyEmpty);
1979 for (idx = 0, it = m_landmarks.begin(); it != m_landmarks.end();
1982 std::vector<int32_t>* cell =
1983 m_grid.cellByPos(it->pose_mean.x, it->pose_mean.y);
1984 cell->push_back(idx);
1987 m_largestDistanceFromOriginIsUpdated =
false;
1998 if (!m_largestDistanceFromOriginIsUpdated)
2001 float maxDistSq = 0, d;
2004 d =
square(it->pose_mean.x) +
square(it->pose_mean.y) +
2006 maxDistSq = max(d, maxDistSq);
2009 m_largestDistanceFromOrigin = sqrt(maxDistSq);
2010 m_largestDistanceFromOriginIsUpdated =
true;
2012 return m_largestDistanceFromOrigin;
2020 std::vector<bool>* otherCorrespondences)
2024 unsigned long distDesc;
2025 double likByDist, likByDesc;
2032 unsigned int idx1, idx2;
2034 CMatrixD dij(1, 3), Cij(3, 3), Cij_1;
2035 double distMahaFlik2;
2049 lm1 += decimation, idx1 += decimation)
2054 lm1->getPose(lm1_pose);
2065 lm2->getPose(lm2_pose);
2070 dij(0, 0) = lm1->pose_mean.x - lm2->pose_mean.x;
2071 dij(0, 1) = lm1->pose_mean.y - lm2->pose_mean.y;
2072 dij(0, 2) = lm1->pose_mean.z - lm2->pose_mean.z;
2081 distMahaFlik2 = dij.multiply_HCHt_scalar(
2084 likByDist = exp(K_dist * distMahaFlik2);
2086 if (likByDist > 1e-2)
2098 mPair(lm2->ID, lm1->ID);
2106 !lm1->features.empty() &&
2107 !lm2->features.empty());
2109 lm1->features[0] && lm2->features[0]);
2112 ->descriptors.SIFT.size() ==
2114 ->descriptors.SIFT.size());
2116 for (it1 = lm1->features[0]
2117 ->descriptors.SIFT.begin(),
2118 it2 = lm2->features[0]
2119 ->descriptors.SIFT.begin();
2120 it1 != lm1->features[0]
2121 ->descriptors.SIFT.end();
2123 distDesc +=
square(*it1 - *it2);
2131 distDesc = (
unsigned long)
2134 likByDesc = exp(K_desc * distDesc);
2135 lik_i += likByDist *
2147 lik *= (0.1 + 0.9 * lik_i);
2161 if (correspondences ==
nullptr)
2163 "When using this method with SIFTLikelihoodMethod = 1, "
2164 "TMatchingPairList *correspondence can not be NULL");
2166 if (otherCorrespondences ==
nullptr)
2168 "When using this method with SIFTLikelihoodMethod = 1, "
2169 "std::vector<bool> *otherCorrespondences can not be NULL");
2171 for (itCorr = correspondences->begin();
2172 itCorr != correspondences->end(); itCorr++)
2185 distMahaFlik2 = dij.multiply_HCHt_scalar(
2192 lik *= exp(-0.5 * dist);
2197 for (k = 1; k <= (theMap->
size() - correspondences->size()); k++)
2213 : insert_SIFTs_from_monocular_images(true),
2214 insert_SIFTs_from_stereo_images(true),
2215 insert_Landmarks_from_range_scans(true),
2216 SiftCorrRatioThreshold(0.4f),
2217 SiftLikelihoodThreshold(0.5f),
2219 SiftEDDThreshold(200.0f),
2220 SIFTMatching3DMethod(0),
2221 SIFTLikelihoodMethod(0),
2223 SIFTsLoadDistanceOfTheMean(3.0f),
2224 SIFTsLoadEllipsoidWidth(0.05f),
2227 SIFTs_stdDisparity(1.0f),
2229 SIFTs_numberOfKLTKeypoints(60),
2230 SIFTs_stereo_maxDepth(15.0f),
2232 SIFTs_epipolar_TH(1.5f),
2235 SIFT_feat_options(vision::
featSIFT)
2245 "\n----------- [CLandmarksMap::TInsertionOptions] ------------ \n\n");
2248 "insert_SIFTs_from_monocular_images = %c\n",
2249 insert_SIFTs_from_monocular_images ?
'Y' :
'N');
2251 "insert_SIFTs_from_stereo_images = %c\n",
2252 insert_SIFTs_from_stereo_images ?
'Y' :
'N');
2254 "insert_Landmarks_from_range_scans = %c\n",
2255 insert_Landmarks_from_range_scans ?
'Y' :
'N');
2258 "SiftCorrRatioThreshold = %f\n",
2259 SiftCorrRatioThreshold);
2261 "SiftLikelihoodThreshold = %f\n",
2262 SiftLikelihoodThreshold);
2264 "SiftEDDThreshold = %f\n", SiftEDDThreshold);
2266 "SIFTMatching3DMethod = %d\n", SIFTMatching3DMethod);
2268 "SIFTLikelihoodMethod = %d\n", SIFTLikelihoodMethod);
2271 "SIFTsLoadDistanceOfTheMean = %f\n",
2272 SIFTsLoadDistanceOfTheMean);
2274 "SIFTsLoadEllipsoidWidth = %f\n",
2275 SIFTsLoadEllipsoidWidth);
2278 "SIFTs_stdXY = %f\n", SIFTs_stdXY);
2280 "SIFTs_stdDisparity = %f\n", SIFTs_stdDisparity);
2283 "SIFTs_numberOfKLTKeypoints = %i\n",
2284 SIFTs_numberOfKLTKeypoints);
2286 "SIFTs_stereo_maxDepth = %f\n",
2287 SIFTs_stereo_maxDepth);
2289 "SIFTs_epipolar_TH = %f\n", SIFTs_epipolar_TH);
2291 "PLOT_IMAGES = %c\n",
2292 PLOT_IMAGES ?
'Y' :
'N');
2294 SIFT_feat_options.dumpToTextStream(out);
2305 insert_SIFTs_from_monocular_images =
iniFile.read_bool(
2306 section.c_str(),
"insert_SIFTs_from_monocular_images",
2307 insert_SIFTs_from_monocular_images);
2308 insert_SIFTs_from_stereo_images =
iniFile.read_bool(
2309 section.c_str(),
"insert_SIFTs_from_stereo_images",
2310 insert_SIFTs_from_stereo_images);
2311 insert_Landmarks_from_range_scans =
iniFile.read_bool(
2312 section.c_str(),
"insert_Landmarks_from_range_scans",
2313 insert_Landmarks_from_range_scans);
2314 SiftCorrRatioThreshold =
iniFile.read_float(
2315 section.c_str(),
"SiftCorrRatioThreshold", SiftCorrRatioThreshold);
2316 SiftLikelihoodThreshold =
iniFile.read_float(
2317 section.c_str(),
"SiftLikelihoodThreshold", SiftLikelihoodThreshold);
2318 SiftEDDThreshold =
iniFile.read_float(
2319 section.c_str(),
"SiftEDDThreshold", SiftEDDThreshold);
2320 SIFTMatching3DMethod =
iniFile.read_int(
2321 section.c_str(),
"SIFTMatching3DMethod", SIFTMatching3DMethod);
2322 SIFTLikelihoodMethod =
iniFile.read_int(
2323 section.c_str(),
"SIFTLikelihoodMethod", SIFTLikelihoodMethod);
2324 SIFTsLoadDistanceOfTheMean =
iniFile.read_float(
2325 section.c_str(),
"SIFTsLoadDistanceOfTheMean",
2326 SIFTsLoadDistanceOfTheMean);
2327 SIFTsLoadEllipsoidWidth =
iniFile.read_float(
2328 section.c_str(),
"SIFTsLoadEllipsoidWidth", SIFTsLoadEllipsoidWidth);
2330 iniFile.read_float(section.c_str(),
"SIFTs_stdXY", SIFTs_stdXY);
2331 SIFTs_stdDisparity =
iniFile.read_float(
2332 section.c_str(),
"SIFTs_stdDisparity", SIFTs_stdDisparity);
2333 SIFTs_numberOfKLTKeypoints =
iniFile.read_int(
2334 section.c_str(),
"SIFTs_numberOfKLTKeypoints",
2335 SIFTs_numberOfKLTKeypoints);
2336 SIFTs_stereo_maxDepth =
iniFile.read_float(
2337 section.c_str(),
"SIFTs_stereo_maxDepth", SIFTs_stereo_maxDepth);
2338 SIFTs_epipolar_TH =
iniFile.read_float(
2339 section.c_str(),
"SIFTs_epipolar_TH", SIFTs_epipolar_TH);
2341 iniFile.read_bool(section.c_str(),
"PLOT_IMAGES", PLOT_IMAGES);
2343 SIFT_feat_options.loadFromConfigFile(
iniFile, section);
2350 : rangeScan2D_decimation(20),
2351 SIFTs_sigma_euclidean_dist(0.30f),
2352 SIFTs_sigma_descriptor_dist(100.0f),
2353 SIFTs_mahaDist_std(4.0f),
2354 SIFTnullCorrespondenceDistance(4.0f),
2355 SIFTs_decimation(1),
2356 SIFT_feat_options(vision::
featSIFT),
2357 beaconRangesStd(0.08f),
2358 beaconRangesUseObservationStd(false),
2359 extRobotPoseStd(0.05f),
2366 : longitude(-4.47763833333333),
2367 latitude(36.71559000000000),
2380 std::ostream& out)
const
2383 "\n----------- [CLandmarksMap::TLikelihoodOptions] ------------ \n\n");
2386 "rangeScan2D_decimation = %i\n",
2389 "SIFTs_sigma_euclidean_dist = %f\n",
2392 "SIFTs_sigma_descriptor_dist = %f\n",
2399 "SIFTnullCorrespondenceDistance = %f\n",
2404 "beaconRangesUseObservationStd = %c\n",
2441 section.c_str(),
"SIFTs_sigma_euclidean_dist",
2444 section.c_str(),
"SIFTs_sigma_descriptor_dist",
2451 section.c_str(),
"SIFTnullCorrespondenceDistance",
2475 section.c_str(),
"beaconRangesUseObservationStd",
2488 : minTimesSeen(2), ellapsedTime(4.0f)
2500 const CPose3D& in_robotPose,
const CPoint3D& in_sensorLocationOnRobot,
2509 point3D = in_robotPose + in_sensorLocationOnRobot;
2521 it->getPose(beaconPDF);
2522 beacon3D = beaconPDF.
mean;
2540 out_Observations.
sensedData.push_back(newMeas);
2562 mrpt::make_aligned_shared<mrpt::opengl::CSetOfObjects>();
2566 mrpt::make_aligned_shared<opengl::CGridPlaneXY>(
2567 -100, 100, -100, 100, 0, 1);
2594 mrpt::make_aligned_shared<opengl::CEllipsoid>();
2596 it->getPose(pointGauss);
2598 ellip->setPose(pointGauss.
mean);
2599 ellip->setCovMatrix(pointGauss.
cov);
2600 ellip->enableDrawSolid3D(
false);
2601 ellip->setQuantiles(3.0);
2602 ellip->set3DsegmentsCount(10);
2603 ellip->setColor(0, 0, 1);
2605 mrpt::format(
"LM.ID=%u",
static_cast<unsigned int>(it->ID)));
2606 ellip->enableShowName(
true);
2608 outObj->insert(ellip);
2621 for (
size_t indx = 0; indx < m_landmarks.size(); indx++)
2623 if (m_landmarks[indx].ID == ID)
return &m_landmarks[indx];
2640 unsigned int ID)
const
2642 for (
size_t indx = 0; indx < m_landmarks.size(); indx++)
2644 if (m_landmarks[indx].ID == ID)
return &m_landmarks[indx];
2679 if (!otherMap)
return 0;
2682 std::deque<CPointPDFGaussian::Ptr> poses3DThis, poses3DOther;
2686 size_t nOther = otherMap->landmarks.size();
2687 size_t otherLandmarkWithCorrespondence = 0;
2690 if (!nThis)
return 0;
2691 if (!nOther)
return 0;
2696 float Tx = pose3DMatrix.get_unsafe(0, 3);
2697 float Ty = pose3DMatrix.get_unsafe(1, 3);
2698 float Tz = pose3DMatrix.get_unsafe(2, 3);
2708 otherMap->landmarks.getLargestDistanceFromOrigin() + 1.0f))
2712 poses3DOther.resize(nOther);
2713 for (
size_t i = 0; i < nOther; i++)
2714 poses3DOther[i] = mrpt::make_aligned_shared<CPointPDFGaussian>();
2716 poses3DThis.resize(nThis);
2717 for (
size_t i = 0; i < nThis; i++)
2718 poses3DThis[i] = mrpt::make_aligned_shared<CPointPDFGaussian>();
2721 for (itOther = otherMap->landmarks.begin(),
2722 itPoseOther = poses3DOther.begin();
2723 itOther != otherMap->landmarks.end(); itOther++, itPoseOther++)
2725 itOther->getPose(**itPoseOther);
2726 (*itPoseOther)->changeCoordinatesReference(otherMapPose);
2730 for (itThis =
landmarks.
begin(), itPoseThis = poses3DThis.begin();
2733 itThis->getPose(**itPoseThis);
2737 for (itOther = otherMap->landmarks.begin(),
2738 itPoseOther = poses3DOther.begin();
2739 itOther != otherMap->landmarks.end(); itOther++, itPoseOther++)
2741 for (itThis =
landmarks.
begin(), itPoseThis = poses3DThis.begin();
2747 (*itPoseThis)->mean.x() - (*itPoseOther)->mean.x(),
2748 (*itPoseThis)->mean.y() - (*itPoseOther)->mean.y(),
2749 (*itPoseThis)->mean.z() - (*itPoseOther)->mean.z());
2755 float distMaha = sqrt(d.multiply_HCHt_scalar(
2758 if (distMaha <
params.maxMahaDistForCorr)
2761 if (!itThis->features.empty() && !itOther->features.empty() &&
2762 itThis->features[0]->descriptors.SIFT.size() ==
2763 itOther->features[0]->descriptors.SIFT.size())
2765 unsigned long descrDist = 0;
2767 for (it1 = itThis->features[0]->descriptors.SIFT.begin(),
2768 it2 = itOther->features[0]->descriptors.SIFT.begin();
2769 it1 != itThis->features[0]->descriptors.SIFT.end();
2771 descrDist +=
square(*it1 - *it2);
2774 sqrt(
static_cast<float>(descrDist)) /
2775 itThis->features[0]->descriptors.SIFT.size();
2777 if (descrDist_f < 1.5f)
2779 otherLandmarkWithCorrespondence++;
2788 return static_cast<float>(otherLandmarkWithCorrespondence) / nOther;
2816 const CPose3D& in_robotPose,
const CPose3D& in_sensorLocationOnRobot,
2818 const float in_stdRange,
const float in_stdYaw,
const float in_stdPitch,
2819 std::vector<size_t>* out_real_associations,
2820 const double spurious_count_mean,
const double spurious_count_std)
const
2828 if (out_real_associations) out_real_associations->clear();
2831 const CPose3D point3D = in_robotPose +
CPose3D(in_sensorLocationOnRobot);
2848 it->getPose(beaconPDF);
2869 if (sensorDetectsIDs)
2878 out_Observations.
sensedData.push_back(newMeas);
2880 if (out_real_associations)
2881 out_real_associations->push_back(idx);
2886 spurious_count_mean, spurious_count_std);
2887 size_t nSpurious = 0;
2888 if (spurious_count_std != 0 || spurious_count_mean != 0)
2894 for (
size_t i = 0; i < nSpurious; i++)
2907 const double pitch =
2922 out_Observations.
sensedData.push_back(newMeas);
2924 if (out_real_associations)
2925 out_real_associations->push_back(