owlps/owlps-positioner/src/autocalibration.hh

96 lines
2.8 KiB
C++
Raw Normal View History

/*
* 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 ;
#include "measurement.hh"
#include <vector>
#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:
struct ap
{
const AccessPoint *ap ;
float weight ; // Weight of the AP in percents
float angle ;
} ;
/// Current AP to generate a SS for
std::tr1::unordered_map<std::string, AccessPoint>::const_iterator rx ;
/// Angle P-RX-O, O being the origin of the trigonometric circle
float origin_angle ;
/// Selected transmitter APs
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)
std::multimap<double,
std::pair<double,
std::tr1::unordered_map<
std::string, AccessPoint>::const_iterator> >
sorted_positive_angles ;
/// 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) ;
/// Sorts the reference APs for a receiver AP
void sort_reference_aps(void) ;
/// Computes the weight of the selected AP(s)
void weight_aps(void) ;
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) ;
/// Computes the SS of the virtual mobile
void compute_ss(void) ;
/// Computes a SS with only one packet in it
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) ;
/// Computes a SS with several packets in it
void compute_multi_packet_ss(void) ;
public:
Autocalibration(const Point3D &_point): point(_point) {}
/// Generates a single reference point
void generate_reference_point(void) ;
} ;
#endif // _OWLPS_POSITIONING_AUTOCALIBRATION_HH_