2012-04-27 17:41:11 +02:00
|
|
|
/*
|
|
|
|
* This file is part of the Owl Positioning System (OwlPS).
|
|
|
|
* OwlPS is a project of the University of Franche-Comté
|
|
|
|
* (Université de Franche-Comté), France.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef _OWLPS_POSITIONING_AUTOCALIBRATION_HH_
|
|
|
|
#define _OWLPS_POSITIONING_AUTOCALIBRATION_HH_
|
|
|
|
|
|
|
|
class AccessPoint ;
|
|
|
|
class Point3D ;
|
2012-05-01 16:23:27 +02:00
|
|
|
|
|
|
|
#include "measurement.hh"
|
2012-04-27 17:41:11 +02:00
|
|
|
|
2012-05-10 10:26:14 +02:00
|
|
|
#include <vector>
|
2012-04-27 17:41:11 +02:00
|
|
|
#include <boost/tr1/unordered_map.hpp>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The class Autocalibration contains the code used to generate single
|
|
|
|
* reference points from the autocalibration measurements.
|
|
|
|
*/
|
|
|
|
class Autocalibration
|
|
|
|
{
|
|
|
|
private:
|
2012-05-01 16:23:27 +02:00
|
|
|
struct ap
|
|
|
|
{
|
|
|
|
const AccessPoint *ap ;
|
|
|
|
float weight ; // Weight of the AP in percents
|
|
|
|
float angle ;
|
|
|
|
} ;
|
|
|
|
|
2012-04-27 17:41:11 +02:00
|
|
|
/// Current AP to generate a SS for
|
|
|
|
std::tr1::unordered_map<std::string, AccessPoint>::const_iterator rx ;
|
2012-05-01 16:23:27 +02:00
|
|
|
/// Angle P-RX-O, O being the origin of the trigonometric circle
|
2012-05-02 16:05:27 +02:00
|
|
|
float origin_angle ;
|
2012-04-27 17:41:11 +02:00
|
|
|
/// Selected transmitter APs
|
2012-05-01 16:23:27 +02:00
|
|
|
std::vector<ap> ref_aps ;
|
|
|
|
/// \brief Angles of the transmitter APs (before M on the trigonometric
|
|
|
|
/// circle)
|
|
|
|
/**
|
|
|
|
* Note that the angles are stored in absolute value.
|
|
|
|
*/
|
|
|
|
std::multimap<double,
|
|
|
|
std::pair<double,
|
|
|
|
std::tr1::unordered_map<
|
|
|
|
std::string, AccessPoint>::const_iterator> >
|
|
|
|
sorted_negative_angles ;
|
|
|
|
/// Angles of the transmitter APs (after M on the trigonometric circle)
|
2012-04-27 17:41:11 +02:00
|
|
|
std::multimap<double,
|
|
|
|
std::pair<double,
|
|
|
|
std::tr1::unordered_map<
|
|
|
|
std::string, AccessPoint>::const_iterator> >
|
2012-05-01 16:23:27 +02:00
|
|
|
sorted_positive_angles ;
|
2012-04-27 17:41:11 +02:00
|
|
|
/// Characteristics of the virtual mobile
|
|
|
|
double vmob_gain, vmob_pow ;
|
|
|
|
/// Generated measurements' list
|
|
|
|
std::tr1::unordered_map<std::string, Measurement> measurements ;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
/// Number of generated "virtual" mobiles
|
|
|
|
static uint32_t nb_virtual_mobiles ;
|
|
|
|
|
|
|
|
/// The coordinates of the reference point to generate
|
|
|
|
const Point3D &point ;
|
|
|
|
|
|
|
|
/// Generates the SSs for all the APs
|
|
|
|
void generate_ss(void) ;
|
2012-05-01 16:23:27 +02:00
|
|
|
/// Sorts the reference APs for a receiver AP
|
|
|
|
void sort_reference_aps(void) ;
|
|
|
|
/// Computes the weight of the selected AP(s)
|
2012-04-27 17:41:11 +02:00
|
|
|
void weight_aps(void) ;
|
2012-05-01 16:23:27 +02:00
|
|
|
void init_ap(
|
|
|
|
std::map<double, std::pair<double, std::tr1::unordered_map<
|
|
|
|
std::string, AccessPoint>::const_iterator> >::const_iterator s) ;
|
|
|
|
/// Weights two APs according to their angles
|
|
|
|
void weight_2_aps(void) ;
|
2012-04-27 18:04:59 +02:00
|
|
|
/// Computes the SS of the virtual mobile
|
|
|
|
void compute_ss(void) ;
|
|
|
|
/// Computes a SS with only one packet in it
|
2012-05-01 16:23:27 +02:00
|
|
|
void compute_single_packet_ss(pkt_id_t pkt_id) ;
|
|
|
|
/// Computes a SS according to the weight of the AP
|
|
|
|
double compute_weighted_ss(
|
|
|
|
unsigned int ap_idx, pkt_id_t pkt_id, float point_dst) ;
|
2012-04-27 18:04:59 +02:00
|
|
|
/// Computes a SS with several packets in it
|
|
|
|
void compute_multi_packet_ss(void) ;
|
|
|
|
|
2012-05-01 16:23:27 +02:00
|
|
|
public:
|
|
|
|
Autocalibration(const Point3D &_point): point(_point) {}
|
|
|
|
|
|
|
|
/// Generates a single reference point
|
|
|
|
void generate_reference_point(void) ;
|
2012-04-27 17:41:11 +02:00
|
|
|
} ;
|
|
|
|
|
|
|
|
#endif // _OWLPS_POSITIONING_AUTOCALIBRATION_HH_
|