103 lines
3.2 KiB
C++
103 lines
3.2 KiB
C++
/*
|
|
* This file is part of the Owl Positioning System (OwlPS) project.
|
|
* It is subject to the copyright notice and license terms in the
|
|
* COPYRIGHT.t2t file found in the top-level directory of this
|
|
* distribution and at
|
|
* http://code.lm7.fr/p/owlps/source/tree/master/COPYRIGHT.t2t
|
|
* No part of the OwlPS Project, including this file, may be copied,
|
|
* modified, propagated, or distributed except according to the terms
|
|
* contained in the COPYRIGHT.t2t file; the COPYRIGHT.t2t file must be
|
|
* distributed along with this file, either separately or by replacing
|
|
* this notice by the COPYRITGHT.t2t file's contents.
|
|
*/
|
|
|
|
|
|
#ifndef _OWLPS_POSITIONING_AUTOCALIBRATION_HH_
|
|
#define _OWLPS_POSITIONING_AUTOCALIBRATION_HH_
|
|
|
|
class AccessPoint ;
|
|
class Point3D ;
|
|
|
|
#include "measurement.hh"
|
|
|
|
#include <vector>
|
|
#include <unordered_map>
|
|
|
|
/**
|
|
* 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::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 ;
|
|
/// 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::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::unordered_map<
|
|
std::string, AccessPoint>::const_iterator> >
|
|
sorted_positive_angles ;
|
|
/// Characteristics of the virtual mobile
|
|
double vmob_gain, vmob_pow ;
|
|
/// Generated measurements' list
|
|
std::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::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 several packets in it
|
|
void compute_multi_packet_ss(void) ;
|
|
/// Computes a SS with only one packet in it
|
|
bool 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) ;
|
|
|
|
public:
|
|
Autocalibration(const Point3D &_point): point(_point) {}
|
|
|
|
/// Generates a single reference point
|
|
void generate_reference_point(void) ;
|
|
} ;
|
|
|
|
#endif // _OWLPS_POSITIONING_AUTOCALIBRATION_HH_
|