130 lines
4.5 KiB
C++
130 lines
4.5 KiB
C++
/*
|
|
* This file is part of the Owl Positioning System (OwlPS).
|
|
* OwlPS is a project of the University of Franche-Comte
|
|
* (Université de Franche-Comté), France.
|
|
*
|
|
* Copyright © Université de Franche-Comté 2007-2012.
|
|
*
|
|
* Corresponding author: Matteo Cypriani <mcy@lm7.fr>
|
|
*
|
|
***********************************************************************
|
|
*
|
|
* This software is governed by the CeCILL license under French law and
|
|
* abiding by the rules of distribution of free software. You can use,
|
|
* modify and/or redistribute the software under the terms of the CeCILL
|
|
* license as circulated by CEA, CNRS and INRIA at the following URL:
|
|
* http://www.cecill.info
|
|
*
|
|
* As a counterpart to the access to the source code and rights to copy,
|
|
* modify and redistribute granted by the license, users are provided
|
|
* only with a limited warranty and the software's authors, the holder
|
|
* of the economic rights, and the successive licensors have only
|
|
* limited liability.
|
|
*
|
|
* In this respect, the user's attention is drawn to the risks
|
|
* associated with loading, using, modifying and/or developing or
|
|
* reproducing the software by the user in light of its specific status
|
|
* of free software, that may mean that it is complicated to manipulate,
|
|
* and that also therefore means that it is reserved for developers and
|
|
* experienced professionals having in-depth computer knowledge. Users
|
|
* are therefore encouraged to load and test the software's suitability
|
|
* as regards their requirements in conditions enabling the security of
|
|
* their systems and/or data to be ensured and, more generally, to use
|
|
* and operate it in the same conditions as regards security.
|
|
*
|
|
* The fact that you are presently reading this means that you have had
|
|
* knowledge of the CeCILL license and that you accept its terms.
|
|
*
|
|
***********************************************************************
|
|
*/
|
|
|
|
|
|
#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 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_
|