114 lines
2.6 KiB
C++
114 lines
2.6 KiB
C++
#include "positioning.hh"
|
|
#include "realposition.hh"
|
|
#include "fbcm.hh"
|
|
#include "frbhmbasic.hh"
|
|
#include "interlinknetworks.hh"
|
|
#include "radar.hh"
|
|
#include "resultlist.hh"
|
|
#include "configuration.hh"
|
|
#include "posexcept.hh"
|
|
#include "stock.hh"
|
|
|
|
#include <owlps.h>
|
|
|
|
using namespace std ;
|
|
|
|
|
|
|
|
/* *** Constructors *** */
|
|
|
|
|
|
Positioning::Positioning()
|
|
{
|
|
initialise_algorithms() ;
|
|
loop() ;
|
|
}
|
|
|
|
|
|
Positioning::~Positioning()
|
|
{
|
|
for (vector<PositioningAlgorithm*>::const_iterator i =
|
|
algorithms.begin() ; i != algorithms.end() ; ++i)
|
|
delete *i ;
|
|
algorithms.clear() ;
|
|
}
|
|
|
|
|
|
|
|
/* *** Operations *** */
|
|
|
|
|
|
void Positioning::initialise_algorithms()
|
|
{
|
|
if (! Configuration::is_configured("positioning.algorithm"))
|
|
throw missing_configuration(
|
|
"No positioning algorithm specified in configuration!") ;
|
|
|
|
const vector<string> &algo_names =
|
|
Configuration::string_vector_value("positioning.algorithm") ;
|
|
|
|
for (vector<string>::const_iterator i = algo_names.begin() ;
|
|
i != algo_names.end() ; ++i)
|
|
{
|
|
if (*i == "Real")
|
|
/* In order to compute the errors of the other algorithms,
|
|
* Real must be the first for each request, so we add it at
|
|
* the begining.
|
|
*/
|
|
algorithms.insert(algorithms.begin(), new RealPosition) ;
|
|
|
|
else if (*i == "FBCM")
|
|
{
|
|
Stock::update_all_friis_indexes() ;
|
|
algorithms.push_back(new FBCM) ;
|
|
}
|
|
|
|
else if (*i == "FRBHMBasic")
|
|
//TODO: Pre-compute all per-ReferencePoint friis indexes?
|
|
algorithms.push_back(new FRBHMBasic) ;
|
|
|
|
else if (*i == "InterlinkNetworks")
|
|
algorithms.push_back(new InterlinkNetworks) ;
|
|
|
|
else if (*i == "RADAR")
|
|
algorithms.push_back(new RADAR) ;
|
|
|
|
else
|
|
throw bad_configuration(
|
|
"The specified positioning_algorithm « "+ *i +
|
|
" » is unknown!") ;
|
|
}
|
|
}
|
|
|
|
|
|
void Positioning::loop()
|
|
{
|
|
vector<PositioningAlgorithm*>::const_iterator algo ;
|
|
|
|
while (! input.eof() && owl_run)
|
|
{
|
|
const Request &request = input.get_next_request() ;
|
|
if (! request)
|
|
continue ;
|
|
|
|
Point3D real_position ;
|
|
bool compute_error = false ;
|
|
ResultList results(&request) ;
|
|
for (algo = algorithms.begin() ; algo != algorithms.end() ;
|
|
++algo)
|
|
{
|
|
Result res((*algo)->compute(request)) ;
|
|
if (compute_error)
|
|
res.compute_error(real_position) ;
|
|
else if ((*algo)->get_name() == "Real")
|
|
{
|
|
compute_error = true ;
|
|
real_position = res.get_position() ;
|
|
}
|
|
results.add(res) ;
|
|
}
|
|
|
|
output.write(results) ;
|
|
}
|
|
}
|