36 f.
printf(
"%u %u %f %f %f %f %f %f %f\n",
45 it->errorSquareAfterTransformation);
54 FILE *f =
os::fopen(filName.c_str(),
"wt");
56 fprintf(f,
"%% ----------------------------------------------------\n");
57 fprintf(f,
"%% File generated automatically by the MRPT method:\n");
58 fprintf(f,
"%% saveAsMATLABScript \n");
59 fprintf(f,
"%% Before calling this script, define the color of lines, eg:\n");
60 fprintf(f,
"%% colorLines=[1 1 1]");
61 fprintf(f,
"%% J.L. Blanco (C) 2005-2012 \n");
62 fprintf(f,
"%% ----------------------------------------------------\n\n");
64 fprintf(f,
"axis equal; hold on;\n");
67 fprintf(f,
"line([%f %f],[%f %f],'Color',colorLines);\n",
72 fprintf(f,
"set(plot([%f %f],[%f %f],'.'),'Color',colorLines,'MarkerSize',15);\n",
87 if (it->other_idx == idx)
95 if (
a.this_idx==
b.this_idx)
96 return (
a.this_idx<
b.this_idx);
97 else return (
a.other_idx<
b.other_idx);
103 return (
a.this_idx==
b.this_idx) && (
a.other_idx==
b.other_idx);
108 if (
a.size()!=
b.size())
111 if (! ( (*it1)==(*it2)))
122 vector<float> errs(
size() );
123 squareErrorVector(
q,errs);
133 vector<float> &ys )
const
135 vector<float> errs(
size() );
136 squareErrorVector(
q,errs,xs,ys);
156 out_sqErrs.resize(
size() );
159 const float ccos = cos(
q.phi());
160 const float csin = sin(
q.phi());
161 const float qx =
q.x();
162 const float qy =
q.y();
166 for (corresp=
begin(), e_i = out_sqErrs.begin();corresp!=
end();++corresp, ++e_i)
168 float xx = qx + ccos * corresp->other_x - csin * corresp->other_y;
169 float yy = qy + csin * corresp->other_x + ccos * corresp->other_y;
170 *e_i =
square( corresp->this_x - xx ) +
square( corresp->this_y - yy );
179 vector<float> &out_sqErrs,
181 vector<float> &ys )
const
183 out_sqErrs.resize(
size() );
189 const float ccos = cos(
q.phi());
190 const float csin = sin(
q.phi());
191 const float qx =
q.x();
192 const float qy =
q.y();
196 for (corresp=
begin(), e_i = out_sqErrs.begin(), xx = xs.begin(), yy = ys.begin();corresp!=
end();++corresp, ++e_i, ++xx,++yy)
198 *xx = qx + ccos * corresp->other_x - csin * corresp->other_y;
199 *yy = qy + csin * corresp->other_x + ccos * corresp->other_y;
200 *e_i =
square( corresp->this_x - *xx ) +
square( corresp->this_y - *yy );
206 std::vector<TMatchingPairConstPtr> bestMatchForThisMap(num_elements_this_map,
TMatchingPairConstPtr(
nullptr));
207 out_filtered_list.clear();
211 for (
auto &
c : *
this)
213 if (bestMatchForThisMap[
c.this_idx] ==
nullptr ||
214 c.errorSquareAfterTransformation < bestMatchForThisMap[
c.this_idx]->errorSquareAfterTransformation
217 bestMatchForThisMap[
c.this_idx] = &
c;
223 for (
auto &
c : *
this) {
224 if (bestMatchForThisMap[
c.this_idx] == &
c)
225 out_filtered_list.push_back(
c);
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle.
This CStream derived class allow using a file as a write-only, binary stream.
bool fileOpenCorrectly()
Returns true if the file was open without errors.
virtual int printf(const char *fmt,...) MRPT_printf_format_check(2
Writes a string to the stream in a textual form.
void filterUniqueRobustPairs(const size_t num_elements_this_map, TMatchingPairList &out_filtered_list) const
Creates a filtered list of pairings with those ones which have a single correspondence which coincide...
void saveAsMATLABScript(const std::string &filName) const
Saves the correspondences as a MATLAB script which draws them.
bool contains(const TMatchingPair &p) const
Test whether the given pair "p" is within the pairings.
void squareErrorVector(const mrpt::poses::CPose2D &q, std::vector< float > &out_sqErrs) const
Returns a vector with the square error between each pair of correspondences in the list,...
float overallSquareErrorAndPoints(const mrpt::poses::CPose2D &q, std::vector< float > &xs, std::vector< float > &ys) const
Computes the overall square error between the 2D points in the list of correspondences,...
float overallSquareError(const mrpt::poses::CPose2D &q) const
Computes the overall square error between the 2D points in the list of correspondences,...
void dumpToFile(const std::string &fileName) const
Saves the correspondences to a text file.
bool indexOtherMapHasCorrespondence(size_t idx) const
Checks if the given index from the "other" map appears in the list.
const Scalar * const_iterator
GLubyte GLubyte GLubyte a
GLsizei const GLchar ** string
GLdouble GLdouble GLdouble GLdouble q
int BASE_IMPEXP fprintf(FILE *fil, const char *format,...) MRPT_NO_THROWS MRPT_printf_format_check(2
An OS-independent version of fprintf.
FILE BASE_IMPEXP * fopen(const char *fileName, const char *mode) MRPT_NO_THROWS
An OS-independent version of fopen.
int BASE_IMPEXP void BASE_IMPEXP fclose(FILE *f)
An OS-independent version of fclose.
This base provides a set of functions for maths stuff.
CONTAINER::Scalar sum(const CONTAINER &v)
Computes the sum of all the elements.
T square(const T x)
Inline function for the square of a number.
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
This namespace provides a OS-independent interface to many useful functions: filenames manipulation,...
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values,...
const_iterator end() const
bool operator==(const CArray< T, N > &x, const CArray< T, N > &y)
bool operator<(const CArray< T, N > &x, const CArray< T, N > &y)
TMatchingPair const * TMatchingPairConstPtr
const_iterator begin() const
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
This file implements several operations that operate element-wise on individual or pairs of container...
A structure for holding correspondences between two sets of points or points-like entities in 2D or 3...