[Positioning] AccessPoint, Mobile, Measurement, ReferencePoint
- Adding WifiDevice and Mobile. AccessPoint and Mobile are sub-classes of WifiDevice. - Measurement: link to Mobile and AccessPoint. - Adding CalibrationMeasurement. - ReferencePoint: add_measurement() and operators, link to CalibrationMeasurement (not Measurement). - Area and Waypoint : using pointers (not references) for attribute setting. - Deleted class ClientInfo (replaced by Mobile).
This commit is contained in:
parent
1808acd870
commit
326f1245ed
|
@ -2,37 +2,6 @@
|
|||
|
||||
|
||||
|
||||
/*** Constructeurs ***/
|
||||
|
||||
|
||||
AccessPoint::AccessPoint(const Point3D &_coordinates,
|
||||
const string &_ip_addr,
|
||||
const string &_mac_addr,
|
||||
const unsigned int &_frequency,
|
||||
const float &_antenna_gain,
|
||||
const float &_trx_power)
|
||||
{
|
||||
coordinates = _coordinates ;
|
||||
ip_addr = _ip_addr ;
|
||||
mac_addr = _mac_addr ;
|
||||
frequency = _frequency ;
|
||||
antenna_gain = PosUtil::channel_to_frequency(_antenna_gain) ;
|
||||
trx_power = _trx_power ;
|
||||
}
|
||||
|
||||
|
||||
AccessPoint::AccessPoint(const AccessPoint &ap)
|
||||
{
|
||||
coordinates = ap.coordinates ;
|
||||
ip_addr = ap.ip_addr ;
|
||||
mac_addr = ap.mac_addr ;
|
||||
frequency = ap.frequency ;
|
||||
antenna_gain = ap.antenna_gain ;
|
||||
trx_power = ap.trx_power ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*** Accesseurs lecture ***/
|
||||
|
||||
|
||||
|
@ -42,36 +11,12 @@ Point3D AccessPoint::get_coordinates() const
|
|||
}
|
||||
|
||||
|
||||
string AccessPoint::get_ip_addr() const
|
||||
{
|
||||
return ip_addr ;
|
||||
}
|
||||
|
||||
|
||||
string AccessPoint::get_mac_addr() const
|
||||
{
|
||||
return mac_addr ;
|
||||
}
|
||||
|
||||
|
||||
unsigned int AccessPoint::get_frequency() const
|
||||
{
|
||||
return frequency ;
|
||||
}
|
||||
|
||||
|
||||
float AccessPoint::get_antenna_gain() const
|
||||
{
|
||||
return antenna_gain ;
|
||||
}
|
||||
|
||||
|
||||
float AccessPoint::get_trx_power() const
|
||||
{
|
||||
return trx_power ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*** Accesseurs écriture ***/
|
||||
|
||||
|
@ -82,49 +27,38 @@ void AccessPoint::set_coordinates(Point3D &_coordinates)
|
|||
}
|
||||
|
||||
|
||||
void AccessPoint::set_ip_addr(const string &_ip_addr)
|
||||
{
|
||||
ip_addr = _ip_addr ;
|
||||
}
|
||||
|
||||
|
||||
void AccessPoint::set_mac_addr(const string &_mac_addr)
|
||||
{
|
||||
mac_addr = _mac_addr ;
|
||||
}
|
||||
|
||||
|
||||
void AccessPoint::set_frequency(unsigned int &_frequency)
|
||||
{
|
||||
frequency = _frequency ;
|
||||
}
|
||||
|
||||
|
||||
void AccessPoint::set_antenna_gain(float &_antenna_gain)
|
||||
{
|
||||
antenna_gain = PosUtil::channel_to_frequency(_antenna_gain) ;
|
||||
}
|
||||
|
||||
|
||||
void AccessPoint::set_trx_power(float &_trx_power)
|
||||
{
|
||||
trx_power = _trx_power ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*** Opérateurs ***/
|
||||
|
||||
|
||||
AccessPoint AccessPoint::operator=(const AccessPoint &ap)
|
||||
{
|
||||
if (this == &ap)
|
||||
return *this ;
|
||||
|
||||
this->WifiDevice::operator=(ap) ;
|
||||
coordinates = ap.coordinates ;
|
||||
frequency = ap.frequency ;
|
||||
|
||||
return *this ;
|
||||
}
|
||||
|
||||
|
||||
bool AccessPoint::operator==(const AccessPoint &ap) const
|
||||
{
|
||||
if (this == &ap)
|
||||
return true ;
|
||||
|
||||
return
|
||||
this->WifiDevice::operator==(ap) &&
|
||||
coordinates == ap.coordinates &&
|
||||
ip_addr == ap.ip_addr &&
|
||||
mac_addr == ap.mac_addr &&
|
||||
frequency == ap.frequency &&
|
||||
antenna_gain == ap.antenna_gain &&
|
||||
trx_power == ap.trx_power ;
|
||||
frequency == ap.frequency ;
|
||||
}
|
||||
|
||||
|
||||
|
@ -134,32 +68,13 @@ bool AccessPoint::operator!=(const AccessPoint &ap) const
|
|||
}
|
||||
|
||||
|
||||
AccessPoint AccessPoint::operator=(const AccessPoint &ap)
|
||||
{
|
||||
if (this == &ap)
|
||||
return *this ;
|
||||
|
||||
coordinates = ap.coordinates ;
|
||||
ip_addr = ap.ip_addr ;
|
||||
mac_addr = ap.mac_addr ;
|
||||
frequency = ap.frequency ;
|
||||
antenna_gain = ap.antenna_gain ;
|
||||
trx_power = ap.trx_power ;
|
||||
|
||||
return *this ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ostream &operator<<(ostream &os, const AccessPoint &ap)
|
||||
{
|
||||
os
|
||||
<< "Coordinates: " << ap.coordinates << endl
|
||||
<< "IP address: " << ap.ip_addr << endl
|
||||
<< "MAC address: " << ap.mac_addr << endl
|
||||
<< "Frequency: " << ap.frequency << " Hz" << endl
|
||||
<< "Antenna gain: " << ap.antenna_gain << "dBi" << endl
|
||||
<< "Output power: " << ap.trx_power << "dBm" ;
|
||||
<< (WifiDevice) ap ;
|
||||
|
||||
return os ;
|
||||
}
|
||||
|
|
|
@ -1,55 +1,51 @@
|
|||
#ifndef _OWLPS_POSITIONING_ACCESSPOINT_HH_
|
||||
#define _OWLPS_POSITIONING_ACCESSPOINT_HH_
|
||||
|
||||
#include "wifidevice.hh"
|
||||
#include "point3d.hh"
|
||||
#include "posutil.hh"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using namespace std ;
|
||||
|
||||
#define AP_DEFAULT_CHANNEL 6
|
||||
#define AP_DEFAULT_ANTENNA_GAIN 2
|
||||
#define AP_DEFAULT_TRX_POWER 20 // 20 dBm = 100 mW
|
||||
#define AP_DEFAULT_ANTENNA_GAIN 5
|
||||
|
||||
class AccessPoint
|
||||
class AccessPoint: public WifiDevice
|
||||
{
|
||||
protected:
|
||||
Point3D coordinates ;
|
||||
string ip_addr ;
|
||||
string mac_addr ;
|
||||
unsigned int frequency ; // Frequency (channel) in Hz
|
||||
float antenna_gain ; // Antenna gain in dBi
|
||||
float trx_power ; // Transmit power in dBm
|
||||
|
||||
public:
|
||||
AccessPoint(const WifiDevice &wd,
|
||||
const Point3D &_coordinates,
|
||||
const unsigned int &_frequency = AP_DEFAULT_CHANNEL):
|
||||
WifiDevice(wd), coordinates(_coordinates), frequency(_frequency) {}
|
||||
AccessPoint(const Point3D &_coordinates,
|
||||
const string &_ip_addr,
|
||||
const string &_mac_addr,
|
||||
const unsigned int &_frequency = AP_DEFAULT_CHANNEL,
|
||||
const float &_antenna_gain = AP_DEFAULT_ANTENNA_GAIN,
|
||||
const float &_trx_power = AP_DEFAULT_TRX_POWER) ;
|
||||
AccessPoint(const AccessPoint &ap) ;
|
||||
const float &_trx_power = WIFIDEVICE_DEFAULT_TRX_POWER,
|
||||
const unsigned int &_frequency = AP_DEFAULT_CHANNEL):
|
||||
WifiDevice(_ip_addr, _mac_addr, _antenna_gain, _trx_power),
|
||||
coordinates(_coordinates), frequency(_frequency) {}
|
||||
AccessPoint(const WifiDevice &wd):
|
||||
WifiDevice(wd), coordinates(Point3D()), frequency(0) {}
|
||||
AccessPoint(const AccessPoint &ap):
|
||||
WifiDevice(ap), coordinates(ap.coordinates), frequency(ap.frequency) {}
|
||||
|
||||
~AccessPoint() {}
|
||||
|
||||
Point3D get_coordinates(void) const ;
|
||||
string get_ip_addr(void) const ;
|
||||
string get_mac_addr(void) const ;
|
||||
unsigned int get_frequency(void) const ;
|
||||
float get_antenna_gain(void) const ;
|
||||
float get_trx_power(void) const ;
|
||||
|
||||
void set_coordinates(Point3D &_coordinates) ;
|
||||
void set_ip_addr(const string &_ip_addr) ;
|
||||
void set_mac_addr(const string &_mac_addr) ;
|
||||
void set_frequency(unsigned int &_frequency) ;
|
||||
void set_antenna_gain(float &_antenna_gain) ;
|
||||
void set_trx_power(float &_trx_power) ;
|
||||
|
||||
bool operator==(const AccessPoint &ap) const;
|
||||
bool operator!=(const AccessPoint &ap) const;
|
||||
AccessPoint operator=(const AccessPoint &ap) ;
|
||||
bool operator==(const AccessPoint &ap) const ;
|
||||
bool operator!=(const AccessPoint &ap) const ;
|
||||
|
||||
friend ostream &operator<<(ostream &os, const AccessPoint &ap) ;
|
||||
} ;
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
/*** Constructeurs ***/
|
||||
|
||||
|
||||
Area::Area(const Building &_building, const string &_name,
|
||||
Area::Area(const Building *_building, const string &_name,
|
||||
const float &_x1, const float &_y1, const float &_z1,
|
||||
const float &_x2, const float &_y2, const float &_z2)
|
||||
{
|
||||
building = (Building *) &_building ;
|
||||
building = (Building *) _building ;
|
||||
name = _name ;
|
||||
|
||||
float x_min, x_max, y_min, y_max, z_min, z_max ;
|
||||
|
@ -111,9 +111,9 @@ Point3D Area::get_p_max() const
|
|||
/*** Accesseurs écriture ***/
|
||||
|
||||
|
||||
void Area::set_building(const Building &_building)
|
||||
void Area::set_building(const Building *_building)
|
||||
{
|
||||
building = (Building *) &_building ;
|
||||
building = (Building *) _building ;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ protected:
|
|||
Point3D p_max ;
|
||||
|
||||
public:
|
||||
Area(const Building &_building, const string &_name = "Unnamed area",
|
||||
Area(const Building *_building, const string &_name = "Unnamed area",
|
||||
const float &_x1 = 0, const float &_y1 = 0, const float &_z1 = 0,
|
||||
const float &_x2 = 0, const float &_y2 = 0, const float &_z2 = 0) ;
|
||||
Area(const Area &a) ;
|
||||
|
@ -33,7 +33,7 @@ public:
|
|||
Point3D get_p_min(void) const ;
|
||||
Point3D get_p_max(void) const ;
|
||||
|
||||
void set_building(const Building &_building) ;
|
||||
void set_building(const Building *_building) ;
|
||||
void set_name(const string &_name) ;
|
||||
void set_x_min(const float &v) ;
|
||||
void set_y_min(const float &v) ;
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
#include "calibrationmeasurement.hh"
|
||||
|
||||
|
||||
|
||||
/*** Accesseurs lecture ***/
|
||||
|
||||
|
||||
ReferencePoint* CalibrationMeasurement::get_reference_point(void) const
|
||||
{
|
||||
return reference_point ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*** Accesseurs écriture ***/
|
||||
|
||||
|
||||
void CalibrationMeasurement::set_reference_point(const ReferencePoint *_rp)
|
||||
{
|
||||
reference_point = (ReferencePoint *) _rp ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*** Opérateurs ***/
|
||||
|
||||
|
||||
CalibrationMeasurement
|
||||
CalibrationMeasurement::operator=(const CalibrationMeasurement &cm)
|
||||
{
|
||||
if (this == &cm)
|
||||
return *this ;
|
||||
|
||||
this->Measurement::operator=(cm) ;
|
||||
reference_point = cm.reference_point ;
|
||||
|
||||
return *this ;
|
||||
}
|
||||
|
||||
|
||||
bool CalibrationMeasurement::operator==(const CalibrationMeasurement &cm)
|
||||
{
|
||||
if (this == &cm)
|
||||
return true ;
|
||||
|
||||
return
|
||||
this->Measurement::operator==(cm) &&
|
||||
reference_point == cm.reference_point ;
|
||||
}
|
||||
|
||||
|
||||
bool CalibrationMeasurement::operator!=(const CalibrationMeasurement &cm)
|
||||
{
|
||||
return !(*this == cm) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ostream &operator<<(ostream &os, const CalibrationMeasurement &cm)
|
||||
{
|
||||
os
|
||||
<< (Measurement) cm
|
||||
<< "Reference point: " << *cm.reference_point ;
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
#ifndef _OWLPS_POSITIONING_CALIBRATIONMEASUREMENT_HH_
|
||||
#define _OWLPS_POSITIONING_CALIBRATIONMEASUREMENT_HH_
|
||||
|
||||
#include "measurement.hh"
|
||||
#include "referencepoint.hh"
|
||||
|
||||
class CalibrationMeasurement: public Measurement
|
||||
{
|
||||
protected:
|
||||
ReferencePoint *reference_point ;
|
||||
|
||||
public:
|
||||
CalibrationMeasurement(const Mobile *_mobile = NULL,
|
||||
const AccessPoint *_ap = NULL,
|
||||
const vector<int> &_ss_list = vector<int>(),
|
||||
ReferencePoint *_reference_point = NULL):
|
||||
Measurement(_mobile, _ap, _ss_list), reference_point(_reference_point) {}
|
||||
CalibrationMeasurement(const CalibrationMeasurement &cm):
|
||||
Measurement(cm), reference_point(cm.reference_point) {}
|
||||
CalibrationMeasurement(const Measurement &m):
|
||||
Measurement(m), reference_point(NULL) {}
|
||||
|
||||
~CalibrationMeasurement() ;
|
||||
|
||||
ReferencePoint* get_reference_point(void) const ;
|
||||
|
||||
void set_reference_point(const ReferencePoint *_rp) ;
|
||||
|
||||
CalibrationMeasurement operator=(const CalibrationMeasurement &cm) ;
|
||||
bool operator==(const CalibrationMeasurement &cm) ;
|
||||
bool operator!=(const CalibrationMeasurement &cm) ;
|
||||
|
||||
friend ostream &operator<<(ostream &os, const CalibrationMeasurement &cm) ;
|
||||
} ;
|
||||
|
||||
#endif // _OWLPS_POSITIONING_CALIBRATIONMEASUREMENT_HH_
|
|
@ -1,152 +0,0 @@
|
|||
#include "clientinfo.hh"
|
||||
|
||||
|
||||
ClientInfo::ClientInfo(const string &ip, const int &port, const float &antg)
|
||||
{
|
||||
#ifdef DEBUG_T
|
||||
cout << "//--> ClientInfo::ClientInfo()" << endl ;
|
||||
fflush(stdout) ;
|
||||
#endif // DEBUG_T
|
||||
|
||||
client_ip = ip;
|
||||
antenna_gain = antg;
|
||||
client_listen_port = port;
|
||||
|
||||
viterbi_iteration = 1 ;
|
||||
|
||||
int N = VITERBI_N, K = VITERBI_K ;
|
||||
viterbi_V.resize(boost::extents[N-1][K]) ; // Allocation du tableau à la bonne taille (les cases sont initialisées à 0 automatiquement).
|
||||
|
||||
#ifdef DEBUG_T
|
||||
cout << "//<-- ClientInfo::ClientInfo()" << endl ;
|
||||
fflush(stdout) ;
|
||||
#endif // DEBUG_T
|
||||
}
|
||||
|
||||
|
||||
|
||||
ClientInfo::ClientInfo(const ClientInfo &c)
|
||||
{
|
||||
#ifdef DEBUG_T
|
||||
cout << "//--> ClientInfo::ClientInfo(ClientInfo)" << endl ;
|
||||
fflush(stdout) ;
|
||||
#endif // DEBUG_T
|
||||
|
||||
client_ip = c.client_ip ;
|
||||
antenna_gain = c.antenna_gain ;
|
||||
client_listen_port = c.client_listen_port ;
|
||||
viterbi_iteration = c.viterbi_iteration ;
|
||||
|
||||
const float_array::size_type *s = c.viterbi_V.shape() ; // Récupération des dimensions de c.viterbi_V.
|
||||
viterbi_V.resize(boost::extents[s[0]][s[1]]) ; // Redimensionnement de viterbi_V aux dimensions de c.viterbi_V.
|
||||
viterbi_V = c.viterbi_V ; // Copie du contenu de c.viterbi_V dans viterbi_V.
|
||||
|
||||
#ifdef DEBUG_T
|
||||
cout << "//<-- ClientInfo::ClientInfo(ClientInfo)" << endl ;
|
||||
fflush(stdout) ;
|
||||
#endif // DEBUG_T
|
||||
}
|
||||
|
||||
|
||||
|
||||
ClientInfo::~ClientInfo()
|
||||
{
|
||||
#ifdef DEBUG_T
|
||||
cout << "//--> ClientInfo::~ClientInfo()" << endl ;
|
||||
fflush(stdout) ;
|
||||
#endif // DEBUG_T
|
||||
|
||||
viterbi_Eprevious.clear();
|
||||
viterbi_Ecurrent.clear();
|
||||
|
||||
#ifdef DEBUG_T
|
||||
cout << "//<-- ClientInfo::~ClientInfo()" << endl ;
|
||||
fflush(stdout) ;
|
||||
#endif // DEBUG_T
|
||||
}
|
||||
|
||||
|
||||
|
||||
ClientInfo ClientInfo::operator=(const ClientInfo &c)
|
||||
{
|
||||
#ifdef DEBUG_T
|
||||
cout << "//--> ClientInfo::operator=()" << endl ;
|
||||
fflush(stdout) ;
|
||||
#endif // DEBUG_T
|
||||
|
||||
if (this == &c)
|
||||
return *this ;
|
||||
|
||||
client_ip = c.client_ip ;
|
||||
antenna_gain = c.antenna_gain ;
|
||||
client_listen_port = c.client_listen_port ;
|
||||
viterbi_iteration = c.viterbi_iteration ;
|
||||
|
||||
const float_array::size_type *s = c.viterbi_V.shape() ; // Récupération des dimensions de c.viterbi_V.
|
||||
viterbi_V.resize(boost::extents[s[0]][s[1]]) ; // Redimensionnement de viterbi_V aux dimensions de c.viterbi_V.
|
||||
viterbi_V = c.viterbi_V ; // Copie du contenu de c.viterbi_V dans viterbi_V.
|
||||
|
||||
#ifdef DEBUG_T
|
||||
cout << "//<-- ClientInfo::operator=()" << endl ;
|
||||
fflush(stdout) ;
|
||||
#endif // DEBUG_T
|
||||
|
||||
return *this ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool ClientInfo::operator==(const ClientInfo &c)
|
||||
{
|
||||
#ifdef DEBUG_T
|
||||
cout << "//--> ClientInfo::operator==()" << endl ;
|
||||
fflush(stdout) ;
|
||||
#endif // DEBUG_T
|
||||
|
||||
if (this == &c)
|
||||
return true ;
|
||||
|
||||
if (client_ip != c.client_ip)
|
||||
return false ;
|
||||
|
||||
if (antenna_gain != c.antenna_gain)
|
||||
return false ;
|
||||
|
||||
if (client_listen_port != c.client_listen_port)
|
||||
return false ;
|
||||
|
||||
if (viterbi_iteration != c.viterbi_iteration)
|
||||
return false ;
|
||||
|
||||
if (viterbi_V != c.viterbi_V)
|
||||
return false ;
|
||||
|
||||
return true ;
|
||||
|
||||
#ifdef DEBUG_T
|
||||
cout << "//<-- ClientInfo::operator==()" << endl ;
|
||||
fflush(stdout) ;
|
||||
#endif // DEBUG_T
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ClientInfo::print_viterbi_V() const
|
||||
{
|
||||
#ifdef DEBUG_T
|
||||
cout << "//--> ClientInfo::print_viterbi_V()" << endl ;
|
||||
fflush(stdout) ;
|
||||
#endif // DEBUG_T
|
||||
|
||||
for (float_index n=0 ; n < viterbi_V.shape()[0] ; n++)
|
||||
{
|
||||
for (float_index k=0 ; k < viterbi_V.shape()[1] ; k++)
|
||||
cout << "[" << viterbi_V[n][k] << "]" ;
|
||||
cout << endl ;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_T
|
||||
cout << "//<-- ClientInfo::print_viterbi_V()" << endl ;
|
||||
fflush(stdout) ;
|
||||
#endif // DEBUG_T
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
#ifndef _CLIENTINFO_HH_
|
||||
#define _CLIENTINFO_HH_
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <boost/multi_array.hpp>
|
||||
|
||||
#include "guinumo.hh"
|
||||
#include "point.hh"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
#define CLIENT_DEFAULT_PORT 7778
|
||||
#define CLIENT_DEFAULT_IP "127.0.0.1"
|
||||
#define CLIENT_DEFAULT_ANTENNA_GAIN 2 // Good default value
|
||||
|
||||
#define VITERBI_N 5
|
||||
#define VITERBI_K 8
|
||||
|
||||
class ClientInfo
|
||||
{
|
||||
public :
|
||||
typedef boost::multi_array<float, 2> float_array ; // On utilise boost::multi_array pour viterbi_V.
|
||||
typedef float_array::index float_index ;
|
||||
|
||||
protected:
|
||||
string client_ip;
|
||||
float antenna_gain;
|
||||
int client_listen_port;
|
||||
vector<Point> viterbi_Ecurrent; // Last vector
|
||||
vector<Point> viterbi_Eprevious; // Previous vector
|
||||
// float viterbi_distances[5];
|
||||
float_array viterbi_V ;
|
||||
unsigned int viterbi_iteration ; // Nombre d'ensembles d'historique qu'on a déjà passés
|
||||
|
||||
public:
|
||||
ClientInfo(const string &ip = CLIENT_DEFAULT_IP, const int &port = CLIENT_DEFAULT_PORT, const float &antg = CLIENT_DEFAULT_ANTENNA_GAIN);
|
||||
ClientInfo(const ClientInfo &c) ;
|
||||
~ClientInfo();
|
||||
|
||||
ClientInfo operator=(const ClientInfo &c) ;
|
||||
bool operator==(const ClientInfo &c) ;
|
||||
|
||||
float getAntennaGain()const
|
||||
{
|
||||
return antenna_gain;
|
||||
} ;
|
||||
vector<Point>& getRef_viterbi_Ecurrent()
|
||||
{
|
||||
return viterbi_Ecurrent;
|
||||
} ;
|
||||
vector<Point>& getRef_viterbi_Eprevious()
|
||||
{
|
||||
return viterbi_Eprevious;
|
||||
} ;
|
||||
unsigned int& getRef_viterbi_iteration()
|
||||
{
|
||||
return viterbi_iteration ;
|
||||
} ;
|
||||
float_array& getRef_viterbi_V()
|
||||
{
|
||||
return viterbi_V;
|
||||
} ;
|
||||
|
||||
void print_viterbi_V() const ;
|
||||
};
|
||||
|
||||
#endif // _CLIENTINFO_HH_
|
|
@ -5,17 +5,20 @@
|
|||
/*** Constructeurs ***/
|
||||
|
||||
|
||||
Measurement::Measurement(const string &_mac_addr, const vector<int> &_ss_list)
|
||||
Measurement::Measurement(const Mobile *_mobile, const AccessPoint *_ap,
|
||||
const vector<int> &_ss_list)
|
||||
{
|
||||
mac_addr = _mac_addr ;
|
||||
ss_list = ssl ;
|
||||
mobile = (Mobile *) _mobile ;
|
||||
ap = (AccessPoint *) _ap ;
|
||||
ss_list = _ss_list ;
|
||||
update_average_ss() ;
|
||||
}
|
||||
|
||||
|
||||
Measurement::Measurement(const Measurement &m)
|
||||
{
|
||||
mac_addr = m.mac_addr ;
|
||||
mobile = m.mobile ;
|
||||
ap = m.ap ;
|
||||
ss_list = m.ss_list ;
|
||||
average_ss = m.average_ss ;
|
||||
}
|
||||
|
@ -31,15 +34,15 @@ Measurement::~Measurement()
|
|||
/*** Accesseurs lecture ***/
|
||||
|
||||
|
||||
string Measurement::get_mobile_mac_addr() const
|
||||
Mobile* Measurement::get_mobile() const
|
||||
{
|
||||
return mobile_mac_addr ;
|
||||
return mobile ;
|
||||
}
|
||||
|
||||
|
||||
string Measurement::get_ap_mac_addr() const
|
||||
AccessPoint* Measurement::get_ap() const
|
||||
{
|
||||
return ap_mac_addr ;
|
||||
return ap ;
|
||||
}
|
||||
|
||||
|
||||
|
@ -56,10 +59,10 @@ float Measurement::get_average_ss() const
|
|||
|
||||
|
||||
/*
|
||||
float Measurement::get_ss_square_distance(const float &ss) const
|
||||
{
|
||||
float Measurement::get_ss_square_distance(const float &ss) const
|
||||
{
|
||||
return ((ss - average_ss) * (ss - average_ss)) ;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
@ -71,9 +74,9 @@ void Measurement::update_average_ss()
|
|||
{
|
||||
average_ss = 0 ;
|
||||
|
||||
for (int i=0 ; i < ss_list ; i++)
|
||||
for (int i=0 ; i < ss_list.size() ; i++)
|
||||
{
|
||||
float ss_mw =
|
||||
float ss_mwatts =
|
||||
pow(10, (float) ss_list[i] / 10.0) +
|
||||
(ss_list.size() * pow(10, average_ss / 10.0)) ;
|
||||
average_ss = 10 * log10(ss_mwatts / ss_list.size()) ;
|
||||
|
@ -81,9 +84,15 @@ void Measurement::update_average_ss()
|
|||
}
|
||||
|
||||
|
||||
void Measurement::set_mac_addr(const string &_mac_addr)
|
||||
void Measurement::set_mobile(const Mobile *_mobile)
|
||||
{
|
||||
mac_addr = _mac_addr ;
|
||||
mobile = (Mobile *) _mobile ;
|
||||
}
|
||||
|
||||
|
||||
void Measurement::set_ap(const AccessPoint *_ap)
|
||||
{
|
||||
ap = (AccessPoint *) _ap ;
|
||||
}
|
||||
|
||||
|
||||
|
@ -101,11 +110,45 @@ void Measurement::add_ss(const int &ss)
|
|||
/*** Opérateurs ***/
|
||||
|
||||
|
||||
Measurement Measurement::operator=(const Measurement &m)
|
||||
{
|
||||
if (this == &m)
|
||||
return *this ;
|
||||
|
||||
mobile = m.mobile ;
|
||||
ap = m.ap ;
|
||||
ss_list = m.ss_list ;
|
||||
average_ss = m.average_ss ;
|
||||
|
||||
return *this ;
|
||||
}
|
||||
|
||||
|
||||
bool Measurement::operator==(const Measurement &m)
|
||||
{
|
||||
if (this == &m)
|
||||
return true ;
|
||||
|
||||
return
|
||||
mobile == m.mobile &&
|
||||
ap == m.ap &&
|
||||
ss_list == m.ss_list &&
|
||||
average_ss == m.average_ss ;
|
||||
}
|
||||
|
||||
|
||||
bool Measurement::operator!=(const Measurement &m)
|
||||
{
|
||||
return !(*this == m) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ostream &operator<<(ostream &os, const Measurement &m)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
os << m.mac_addr << "->";
|
||||
os << m.mobile->get_mac_addr() << "->" << m.ap->get_mac_addr() << ": " ;
|
||||
if (m.ss_list.size() == 0)
|
||||
os << "No values";
|
||||
else
|
||||
|
|
|
@ -34,8 +34,13 @@ public:
|
|||
float get_average_ss() const ;
|
||||
//float get_ss_square_distance(const float &ss) const ;
|
||||
|
||||
void set_mac_addr(const string &_mac_addr) ;
|
||||
void add_ss_value(const int &ss) ;
|
||||
void set_mobile(const Mobile *_mobile) ;
|
||||
void set_ap(const AccessPoint *_ap) ;
|
||||
void add_ss(const int &ss) ;
|
||||
|
||||
Measurement operator=(const Measurement &m) ;
|
||||
bool operator==(const Measurement &m) ;
|
||||
bool operator!=(const Measurement &m) ;
|
||||
|
||||
friend ostream &operator<<(ostream &os, const Measurement &m) ;
|
||||
} ;
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
#include "mobile.hh"
|
||||
|
||||
|
||||
|
||||
/*** Opérateurs ***/
|
||||
|
||||
|
||||
Mobile Mobile::operator=(const Mobile &m)
|
||||
{
|
||||
if (this == &m)
|
||||
return *this ;
|
||||
|
||||
this->WifiDevice::operator=(m) ;
|
||||
|
||||
return *this ;
|
||||
}
|
||||
|
||||
|
||||
bool Mobile::operator==(const Mobile &m) const
|
||||
{
|
||||
if (this == &m)
|
||||
return true ;
|
||||
|
||||
return
|
||||
this->WifiDevice::operator==(m) ;
|
||||
}
|
||||
|
||||
|
||||
bool Mobile::operator!=(const Mobile &m) const
|
||||
{
|
||||
return !(*this == m) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ostream &operator<<(ostream &os, const Mobile &m)
|
||||
{
|
||||
os << (WifiDevice) m ;
|
||||
|
||||
return os ;
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
#ifndef _OWLPS_POSITIONING_MOBILE_HH_
|
||||
#define _OWLPS_POSITIONING_MOBILE_HH_
|
||||
|
||||
#include "wifidevice.hh"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using namespace std ;
|
||||
|
||||
#define MOBILE_DEFAULT_ANTENNA_GAIN 2
|
||||
|
||||
class Mobile: public WifiDevice
|
||||
{
|
||||
public:
|
||||
Mobile(const string &_ip_addr,
|
||||
const string &_mac_addr,
|
||||
const float &_antenna_gain = MOBILE_DEFAULT_ANTENNA_GAIN,
|
||||
const float &_trx_power = WIFIDEVICE_DEFAULT_TRX_POWER):
|
||||
WifiDevice(_ip_addr, _mac_addr, _antenna_gain, _trx_power) {}
|
||||
Mobile(const WifiDevice &wd):
|
||||
WifiDevice(wd) {}
|
||||
Mobile(const Mobile &m):
|
||||
WifiDevice(m) {}
|
||||
|
||||
~Mobile() {}
|
||||
|
||||
Mobile operator=(const Mobile &m) ;
|
||||
bool operator==(const Mobile &m) const ;
|
||||
bool operator!=(const Mobile &m) const ;
|
||||
|
||||
friend ostream &operator<<(ostream &os, const Mobile &m) ;
|
||||
} ;
|
||||
|
||||
#endif // _OWLPS_POSITIONING_MOBILE_HH_
|
|
@ -157,6 +157,9 @@ Point3D Point3D::operator=(const Point3D &p)
|
|||
|
||||
bool Point3D::operator==(const Point3D &p) const
|
||||
{
|
||||
if (this == &p)
|
||||
return true ;
|
||||
|
||||
return
|
||||
x == p.x &&
|
||||
y == p.y &&
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
|
||||
|
||||
/*** Constructeurs ***/
|
||||
|
||||
|
||||
ReferencePoint::~ReferencePoint()
|
||||
{
|
||||
measurements.clear() ;
|
||||
|
@ -9,19 +12,34 @@ ReferencePoint::~ReferencePoint()
|
|||
|
||||
|
||||
|
||||
vector<Measurement> ReferencePoint::get_measurements() const
|
||||
/*** Accesseurs lecture ***/
|
||||
|
||||
|
||||
vector<CalibrationMeasurement> ReferencePoint::get_measurements() const
|
||||
{
|
||||
return measurements ;
|
||||
}
|
||||
|
||||
// float ReferencePoint::getSsSquareDistance(const vector<Measurement> &m) const
|
||||
|
||||
|
||||
/*** Accesseurs écriture ***/
|
||||
|
||||
|
||||
void ReferencePoint::add_measurement(const CalibrationMeasurement &cm)
|
||||
{
|
||||
measurements.push_back(cm) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// float ReferencePoint::getSsSquareDistance(const vector<CalibrationMeasurement> &m) const
|
||||
// {
|
||||
// unsigned int i, j;
|
||||
// float ret = 0;
|
||||
// bool found;
|
||||
// vector<Measurement> ref_m = measurements;
|
||||
// vector<Measurement> test_m = m;
|
||||
// Measurement new_meas;
|
||||
// vector<CalibrationMeasurement> ref_m = measurements;
|
||||
// vector<CalibrationMeasurement> test_m = m;
|
||||
// CalibrationMeasurement new_meas;
|
||||
|
||||
// new_meas.addSsValue(-95);
|
||||
|
||||
|
@ -79,7 +97,7 @@ vector<Measurement> ReferencePoint::get_measurements() const
|
|||
// void ReferencePoint::addMeasurement(const string &mac_a, const int &value)
|
||||
// {
|
||||
// unsigned int i;
|
||||
// Measurement m;
|
||||
// CalibrationMeasurement m;
|
||||
// bool inserted = false;
|
||||
|
||||
// for (i = 0 ; i < measurements.size() ; i++)
|
||||
|
@ -121,6 +139,9 @@ vector<Measurement> ReferencePoint::get_measurements() const
|
|||
|
||||
|
||||
|
||||
/*** Opérateurs ***/
|
||||
|
||||
|
||||
ReferencePoint ReferencePoint::operator=(const ReferencePoint &rp)
|
||||
{
|
||||
if (this == &rp)
|
||||
|
@ -133,6 +154,23 @@ ReferencePoint ReferencePoint::operator=(const ReferencePoint &rp)
|
|||
}
|
||||
|
||||
|
||||
ReferencePoint ReferencePoint::operator==(const ReferencePoint &rp) const
|
||||
{
|
||||
if (this == &rp)
|
||||
return true ;
|
||||
|
||||
return
|
||||
this->Point3D::operator==(rp) &&
|
||||
measurements == rp.measurements ;
|
||||
}
|
||||
|
||||
|
||||
ReferencePoint ReferencePoint::operator!=(const ReferencePoint &rp) const
|
||||
{
|
||||
return !(*this == rp) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ostream &operator<<(ostream &os, ReferencePoint &rp)
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define _OWLPS_POSITIONING_REFERENCEPOINT_HH_
|
||||
|
||||
#include "point3d.hh"
|
||||
#include "measurement.hh"
|
||||
#include "calibrationmeasurement.hh"
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
@ -12,7 +12,7 @@ using namespace std ;
|
|||
class ReferencePoint: public Point3D
|
||||
{
|
||||
protected:
|
||||
vector<Measurement> measurements ;
|
||||
vector<CalibrationMeasurement> measurements ;
|
||||
|
||||
public:
|
||||
ReferencePoint(const float &_x = 0, const float &_y = 0, const float &_z = 0):
|
||||
|
@ -23,13 +23,15 @@ public:
|
|||
|
||||
~ReferencePoint() ;
|
||||
|
||||
vector<Measurement> get_measurements() const ;
|
||||
vector<CalibrationMeasurement> get_measurements() const ;
|
||||
|
||||
// float get_ss_square_distance(const vector<Measurement> &m) const ;
|
||||
// void add_measurement(const string &mac_a, const int &value) ;
|
||||
void add_measurement(const CalibrationMeasurement &cm) ;
|
||||
// float get_ss_square_distance(const vector<CalibrationMeasurement> &m) const ;
|
||||
// bool get_power_for_ap(const string &ap_mac, float *p) const ;
|
||||
|
||||
ReferencePoint operator=(const ReferencePoint &rp) ;
|
||||
ReferencePoint operator==(const ReferencePoint &rp) const ;
|
||||
ReferencePoint operator!=(const ReferencePoint &rp) const ;
|
||||
|
||||
friend ostream &operator<<(ostream &os, ReferencePoint &rp) ;
|
||||
} ;
|
||||
|
|
|
@ -5,17 +5,17 @@
|
|||
/*** Constructeurs ***/
|
||||
|
||||
|
||||
Waypoint::Waypoint(const Building &b, const Point3D &p): Point3D(p)
|
||||
Waypoint::Waypoint(const Building *_b, const Point3D &p): Point3D(p)
|
||||
{
|
||||
buildings.push_back((Building *) &b) ;
|
||||
buildings.push_back((Building *) _b) ;
|
||||
}
|
||||
|
||||
|
||||
Waypoint::Waypoint(const Building &b,
|
||||
Waypoint::Waypoint(const Building *_b,
|
||||
const float &_x, const float &_y, const float &_z
|
||||
): Point3D(_x, _y, _z)
|
||||
{
|
||||
buildings.push_back((Building *) &b) ;
|
||||
buildings.push_back((Building *) _b) ;
|
||||
}
|
||||
|
||||
|
||||
|
@ -48,9 +48,9 @@ vector<Building*> Waypoint::get_buildings() const
|
|||
/*** Accesseurs écriture ***/
|
||||
|
||||
|
||||
void Waypoint::add_building(const Building &_b)
|
||||
void Waypoint::add_building(const Building *_b)
|
||||
{
|
||||
buildings.push_back((Building *) &_b) ;
|
||||
buildings.push_back((Building *) _b) ;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -13,8 +13,8 @@ protected:
|
|||
vector<Building*> buildings ;
|
||||
|
||||
public:
|
||||
Waypoint(const Building &b, const Point3D &p) ;
|
||||
Waypoint(const Building &b, const float &_x = 0, const float &_y = 0,
|
||||
Waypoint(const Building *_b, const Point3D &p) ;
|
||||
Waypoint(const Building *_b, const float &_x = 0, const float &_y = 0,
|
||||
const float &_z = 0) ;
|
||||
Waypoint(const Point3D &p): Point3D(p) {}
|
||||
Waypoint(const Waypoint &wp): Point3D(wp), buildings(wp.buildings) {}
|
||||
|
@ -24,7 +24,7 @@ public:
|
|||
Building* get_1st_building(void) const ;
|
||||
vector<Building*> get_buildings(void) const ;
|
||||
|
||||
void add_building(const Building &building) ;
|
||||
void add_building(const Building &_b) ;
|
||||
|
||||
Waypoint operator=(const Waypoint &wp) ;
|
||||
bool operator==(const Waypoint &wp) const ;
|
||||
|
|
|
@ -0,0 +1,132 @@
|
|||
#include "wifidevice.hh"
|
||||
|
||||
|
||||
|
||||
/*** Constructeurs ***/
|
||||
|
||||
|
||||
WifiDevice::WifiDevice(const string &_ip_addr,
|
||||
const string &_mac_addr,
|
||||
const float &_antenna_gain,
|
||||
const float &_trx_power)
|
||||
{
|
||||
ip_addr = _ip_addr ;
|
||||
mac_addr = _mac_addr ;
|
||||
antenna_gain = PosUtil::channel_to_frequency(_antenna_gain) ;
|
||||
trx_power = _trx_power ;
|
||||
}
|
||||
|
||||
|
||||
WifiDevice::WifiDevice(const WifiDevice &wd)
|
||||
{
|
||||
ip_addr = wd.ip_addr ;
|
||||
mac_addr = wd.mac_addr ;
|
||||
antenna_gain = wd.antenna_gain ;
|
||||
trx_power = wd.trx_power ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*** Accesseurs lecture ***/
|
||||
|
||||
|
||||
string WifiDevice::get_ip_addr() const
|
||||
{
|
||||
return ip_addr ;
|
||||
}
|
||||
|
||||
|
||||
string WifiDevice::get_mac_addr() const
|
||||
{
|
||||
return mac_addr ;
|
||||
}
|
||||
|
||||
|
||||
float WifiDevice::get_antenna_gain() const
|
||||
{
|
||||
return antenna_gain ;
|
||||
}
|
||||
|
||||
|
||||
float WifiDevice::get_trx_power() const
|
||||
{
|
||||
return trx_power ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*** Accesseurs écriture ***/
|
||||
|
||||
|
||||
void WifiDevice::set_ip_addr(const string &_ip_addr)
|
||||
{
|
||||
ip_addr = _ip_addr ;
|
||||
}
|
||||
|
||||
|
||||
void WifiDevice::set_mac_addr(const string &_mac_addr)
|
||||
{
|
||||
mac_addr = _mac_addr ;
|
||||
}
|
||||
|
||||
|
||||
void WifiDevice::set_antenna_gain(float &_antenna_gain)
|
||||
{
|
||||
antenna_gain = PosUtil::channel_to_frequency(_antenna_gain) ;
|
||||
}
|
||||
|
||||
|
||||
void WifiDevice::set_trx_power(float &_trx_power)
|
||||
{
|
||||
trx_power = _trx_power ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*** Opérateurs ***/
|
||||
|
||||
|
||||
WifiDevice WifiDevice::operator=(const WifiDevice &wd)
|
||||
{
|
||||
if (this == &wd)
|
||||
return *this ;
|
||||
|
||||
ip_addr = wd.ip_addr ;
|
||||
mac_addr = wd.mac_addr ;
|
||||
antenna_gain = wd.antenna_gain ;
|
||||
trx_power = wd.trx_power ;
|
||||
|
||||
return *this ;
|
||||
}
|
||||
|
||||
|
||||
bool WifiDevice::operator==(const WifiDevice &wd) const
|
||||
{
|
||||
if (this == &wd)
|
||||
return true ;
|
||||
|
||||
return
|
||||
ip_addr == wd.ip_addr &&
|
||||
mac_addr == wd.mac_addr &&
|
||||
antenna_gain == wd.antenna_gain &&
|
||||
trx_power == wd.trx_power ;
|
||||
}
|
||||
|
||||
|
||||
bool WifiDevice::operator!=(const WifiDevice &wd) const
|
||||
{
|
||||
return !(*this == wd) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ostream &operator<<(ostream &os, const WifiDevice &wd)
|
||||
{
|
||||
os
|
||||
<< "IP address: " << wd.ip_addr << endl
|
||||
<< "MAC address: " << wd.mac_addr << endl
|
||||
<< "Antenna gain: " << wd.antenna_gain << "dBi" << endl
|
||||
<< "Output power: " << wd.trx_power << "dBm" ;
|
||||
|
||||
return os ;
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
#ifndef _OWLPS_POSITIONING_WIFIDEVICE_HH_
|
||||
#define _OWLPS_POSITIONING_WIFIDEVICE_HH_
|
||||
|
||||
#include "posutil.hh"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using namespace std ;
|
||||
|
||||
#define WIFIDEVICE_DEFAULT_ANTENNA_GAIN 2
|
||||
#define WIFIDEVICE_DEFAULT_TRX_POWER 20 // 20 dBm = 100 mW
|
||||
|
||||
class WifiDevice
|
||||
{
|
||||
protected:
|
||||
string ip_addr ;
|
||||
string mac_addr ;
|
||||
float antenna_gain ; // Antenna gain in dBi
|
||||
float trx_power ; // Transmit power in dBm
|
||||
|
||||
public:
|
||||
WifiDevice(const string &_ip_addr,
|
||||
const string &_mac_addr,
|
||||
const float &_antenna_gain = WIFIDEVICE_DEFAULT_ANTENNA_GAIN,
|
||||
const float &_trx_power = WIFIDEVICE_DEFAULT_TRX_POWER) ;
|
||||
WifiDevice(const WifiDevice &wd) ;
|
||||
|
||||
~WifiDevice() {}
|
||||
|
||||
string get_ip_addr(void) const ;
|
||||
string get_mac_addr(void) const ;
|
||||
float get_antenna_gain(void) const ;
|
||||
float get_trx_power(void) const ;
|
||||
|
||||
void set_ip_addr(const string &_ip_addr) ;
|
||||
void set_mac_addr(const string &_mac_addr) ;
|
||||
void set_antenna_gain(float &_antenna_gain) ;
|
||||
void set_trx_power(float &_trx_power) ;
|
||||
|
||||
WifiDevice operator=(const WifiDevice &wd) ;
|
||||
bool operator==(const WifiDevice &wd) const ;
|
||||
bool operator!=(const WifiDevice &wl) const ;
|
||||
|
||||
friend ostream &operator<<(ostream &os, const WifiDevice &wd) ;
|
||||
} ;
|
||||
|
||||
#endif // _OWLPS_POSITIONING_WIFIDEVICE_HH_
|
Loading…
Reference in New Issue