62 cout <<
"Saving map1.pcd and map2.pcd in PCL format...\n";
102 ICP.
Align(&m1, &m2, initialPose, &runningTime, (
void*)&info);
105 "ICP run in %.02fms, %d iterations (%.02fms/iter), %.01f%% goodness\n " 107 runningTime * 1000, info.nIterations,
108 runningTime * 1000.0f / info.nIterations, info.goodness * 100);
110 cout <<
"Mean of estimation: " << pdf->getMeanVal() << endl << endl;
115 cout <<
"Covariance of estimation: " << endl << gPdf.
cov << endl;
117 cout <<
" std(x): " << sqrt(gPdf.
cov(0, 0)) << endl;
118 cout <<
" std(y): " << sqrt(gPdf.
cov(1, 1)) << endl;
119 cout <<
" std(phi): " <<
RAD2DEG(sqrt(gPdf.
cov(2, 2))) <<
" (deg)" << endl;
128 cout <<
"-> Saving reference map as scan1.txt" << endl;
131 cout <<
"-> Saving map to align as scan2.txt" << endl;
134 cout <<
"-> Saving transformed map to align as scan2_trans.txt" << endl;
139 cout <<
"-> Saving MATLAB script for drawing 2D ellipsoid as view_ellip.m" 144 MEAN2D[0] = gPdf.
mean.
x();
145 MEAN2D[1] = gPdf.
mean.
y();
147 ofstream f(
"view_ellip.m");
152 #if MRPT_HAS_WXWIDGETS 162 vector<float> map1_xs, map1_ys, map1_zs;
164 win.plot(map1_xs, map1_ys,
"b.3",
"map1");
167 vector<float> map2_xs, map2_ys, map2_zs;
169 win.plot(map2_xs, map2_ys,
"r.3",
"map2");
172 win.plotEllipse(MEAN2D[0], MEAN2D[1], COV22, 3.0,
"b2",
"cov");
174 win.axis(-1, 10, -6, 6);
177 cout <<
"Close the window to exit" << endl;
183 int main(
int argc,
char** argv)
199 cout <<
"MRPT exception caught: " << e.what() << endl;
204 printf(
"Another exception!!");
void copyFrom(const CPosePDF &o) override
Copy operator, translating if necesary (for example, between particles and gaussian representations) ...
bool save2D_to_text_file(const std::string &file) const
Save to a text file.
std::string MATLAB_plotCovariance2D(const CMatrixFloat &cov22, const CVectorFloat &mean, const float &stdCount, const std::string &style=std::string("b"), const size_t &nEllipsePoints=30)
Generates a string with the MATLAB commands required to plot an confidence interval (ellipse) for a 2...
CPose2D mean
The mean value.
double RAD2DEG(const double x)
Radians to degrees.
void changeCoordinatesReference(const mrpt::poses::CPose2D &b)
Replace each point by (pose compounding operator).
Template for column vectors of dynamic size, compatible with Eigen.
Create a GUI window and display plots with MATLAB-like interfaces and commands.
TICPAlgorithm ICP_algorithm
The algorithm to use (default: icpClassic).
mrpt::poses::CPosePDF::Ptr Align(const mrpt::maps::CMetricMap *m1, const mrpt::maps::CMetricMap *m2, const mrpt::poses::CPose2D &grossEst, float *runningTime=nullptr, void *info=nullptr)
The method for aligning a pair of metric maps, aligning only 2D + orientation.
Several implementations of ICP (Iterative closest point) algorithms for aligning two point maps or a ...
double DEG2RAD(const double x)
Degrees to radians.
void example2DRangeScan(mrpt::obs::CObservation2DRangeScan &s, int i=0)
Example 2D lidar scans (form a venerable SICK LMS200).
A cloud of points in 2D or 3D, which can be built from a sequence of laser scans. ...
double smallestThresholdDist
The size for threshold such that iterations will stop, since it is considered precise enough...
TConfigParams options
The options employed by the ICP align.
CMatrixDynamic< float > CMatrixFloat
Declares a matrix of float numbers (non serializable).
mrpt::math::CMatrixDouble33 cov
The 3x3 covariance matrix.
This base provides a set of functions for maths stuff.
Declares a class that represents a Probability Density function (PDF) of a 2D pose ...
void getAllPoints(VECTOR &xs, VECTOR &ys, VECTOR &zs, size_t decimation=1) const
Returns a copy of the 2D/3D points as a std::vector of float coordinates.
unsigned int maxIterations
Maximum number of iterations to run.
This namespace contains representation of robot actions and observations.
bool doRANSAC
Perform a RANSAC step, mrpt::tfest::se2_l2_robust(), after the ICP convergence, to obtain a better es...
virtual bool savePCDFile(const std::string &filename, bool save_as_binary) const
Save the point cloud as a PCL PCD file, in either ASCII or binary format (requires MRPT built against...
double x() const
Common members of all points & poses classes.
mrpt::gui::CDisplayWindow3D::Ptr win
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
TICPAlgorithm
The ICP algorithm selection, used in mrpt::slam::CICP::options mrpt_slam_grp.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
A "CObservation"-derived class that represents a 2D range scan measurement (typically from a laser sc...
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle...
double ALFA
The scale factor for thresholds everytime convergence is achieved.
void setSize(size_t row, size_t col, bool zeroNewElements=false)
Changes the size of matrix, maintaining the previous contents.
The ICP algorithm return information.
double thresholdDist
Initial threshold distance for two points to become a correspondence.
void dumpToConsole() const
Just like dumpToTextStream() but sending the text to the console (std::cout)
This template class provides the basic functionality for a general 2D any-size, resizable container o...
bool insertObservation(const mrpt::obs::CObservation &obs, const mrpt::poses::CPose3D *robotPose=nullptr)
Insert the observation information into this map.
CMatrixDynamic< double > CMatrixDouble
Declares a matrix of double numbers (non serializable).