[Positioning] Result: compute error if possible
If the real coordinates are passed to the constructor, the distance error is computed. One can also use Result::compute_error() on a constructed object.
This commit is contained in:
parent
2d2b49947a
commit
6c3647410d
|
@ -7,6 +7,28 @@ using namespace std ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* *** Constructors *** */
|
||||||
|
|
||||||
|
|
||||||
|
Result::Result(const Point3D &_position, const std::string &_algorithm,
|
||||||
|
const Point3D &real_position):
|
||||||
|
position(_position), algorithm(_algorithm)
|
||||||
|
{
|
||||||
|
compute_error(real_position) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* *** Write accessors *** */
|
||||||
|
|
||||||
|
|
||||||
|
void Result::compute_error(const Point3D &real_position)
|
||||||
|
{
|
||||||
|
error = position.distance(real_position) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* *** Operators *** */
|
/* *** Operators *** */
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,7 +64,9 @@ const string Result::to_csv() const
|
||||||
<< algorithm
|
<< algorithm
|
||||||
<< ';' << position.get_x()
|
<< ';' << position.get_x()
|
||||||
<< ';' << position.get_y()
|
<< ';' << position.get_y()
|
||||||
<< ';' << position.get_z() ;
|
<< ';' << position.get_z()
|
||||||
|
<< ';' << "Error"
|
||||||
|
<< ';' << error ;
|
||||||
|
|
||||||
return csv_line.str() ;
|
return csv_line.str() ;
|
||||||
}
|
}
|
||||||
|
@ -54,5 +78,7 @@ std::ostream& operator<<(ostream &os, const Result &r)
|
||||||
os
|
os
|
||||||
<< "The result of the algorithm " << r.algorithm
|
<< "The result of the algorithm " << r.algorithm
|
||||||
<< " is: " << r.position ;
|
<< " is: " << r.position ;
|
||||||
|
if (r.error >= 0)
|
||||||
|
os << ", error = " << r.error << " m" ;
|
||||||
return os ;
|
return os ;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,20 +9,33 @@
|
||||||
class Result
|
class Result
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
/// Computed coordinates of the mobile
|
||||||
Point3D position ;
|
Point3D position ;
|
||||||
|
/// Algorithm used to compute the position
|
||||||
std::string algorithm ;
|
std::string algorithm ;
|
||||||
|
/// Distance error between the real coordinates and the computed point
|
||||||
|
/** The error is set to -1 if the real coordinates are unknown. */
|
||||||
|
float error ;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Result(const std::string &_algorithm = "UnknownAlgorithm"):
|
Result(const std::string &_algorithm = "UnknownAlgorithm"):
|
||||||
algorithm(_algorithm) {}
|
algorithm(_algorithm), error(-1) {}
|
||||||
Result(const Point3D &_position, const std::string &_algorithm):
|
Result(const Point3D &_position, const std::string &_algorithm):
|
||||||
position(_position), algorithm(_algorithm) {}
|
position(_position), algorithm(_algorithm), error(-1) {}
|
||||||
|
Result(const Point3D &_position, const std::string &_algorithm,
|
||||||
|
const Point3D &real_position) ;
|
||||||
~Result(void) {}
|
~Result(void) {}
|
||||||
|
|
||||||
/** @name Read accessors */
|
/** @name Read accessors */
|
||||||
//@{
|
//@{
|
||||||
const std::string& get_algorithm(void) const ;
|
const std::string& get_algorithm(void) const ;
|
||||||
const Point3D& get_position(void) const ;
|
const Point3D& get_position(void) const ;
|
||||||
|
float get_error(void) const ;
|
||||||
|
//@}
|
||||||
|
|
||||||
|
/** @name Write accessors */
|
||||||
|
//@{
|
||||||
|
void compute_error(const Point3D &real_position) ;
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
/** @name Operators */
|
/** @name Operators */
|
||||||
|
@ -59,6 +72,12 @@ inline const Point3D& Result::get_position() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline float Result::get_error() const
|
||||||
|
{
|
||||||
|
return error ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* *** Operators *** */
|
/* *** Operators *** */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue