[Positioning] Add positioning algorithm FBCM
Add class FBCM. AccessPoint: Add attribute friis_index. Measurement: Add function get_ss_list_size(). Stock: Add function update_all_friis_indexes().
This commit is contained in:
parent
a05c61a3c1
commit
e12db08b0d
|
@ -54,6 +54,7 @@ OBJ_LIST = \
|
||||||
result.o \
|
result.o \
|
||||||
minmax.o \
|
minmax.o \
|
||||||
interlinknetworks.o \
|
interlinknetworks.o \
|
||||||
|
fbcm.o \
|
||||||
radar.o \
|
radar.o \
|
||||||
realposition.o \
|
realposition.o \
|
||||||
configuration.o \
|
configuration.o \
|
||||||
|
@ -201,6 +202,8 @@ $(OBJ_DIR)/minmax.o: \
|
||||||
$(OBJ_DIR)/accesspoint.o
|
$(OBJ_DIR)/accesspoint.o
|
||||||
$(OBJ_DIR)/interlinknetworks.o: \
|
$(OBJ_DIR)/interlinknetworks.o: \
|
||||||
$(OBJ_DIR)/multilaterationalgorithm.o
|
$(OBJ_DIR)/multilaterationalgorithm.o
|
||||||
|
$(OBJ_DIR)/fbcm.o: \
|
||||||
|
$(OBJ_DIR)/multilaterationalgorithm.o
|
||||||
$(OBJ_DIR)/radar.o: \
|
$(OBJ_DIR)/radar.o: \
|
||||||
$(OBJ_DIR)/cartographyalgorithm.o
|
$(OBJ_DIR)/cartographyalgorithm.o
|
||||||
$(OBJ_DIR)/realposition.o: \
|
$(OBJ_DIR)/realposition.o: \
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
Stock ? (Pour l'instant ils ne sont pas dans Stock.)
|
Stock ? (Pour l'instant ils ne sont pas dans Stock.)
|
||||||
|
|
||||||
- AccessPoint
|
- AccessPoint
|
||||||
° Attribut float friis_index ?
|
|
||||||
° Lancer une exception si le canal Wi-Fi est mauvais (ou
|
° Lancer une exception si le canal Wi-Fi est mauvais (ou
|
||||||
directement dans PosUtil::channel_to_frequency() ?).
|
directement dans PosUtil::channel_to_frequency() ?).
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ const AccessPoint& AccessPoint::operator=(const AccessPoint &source)
|
||||||
this->WifiDevice::operator=(source) ;
|
this->WifiDevice::operator=(source) ;
|
||||||
coordinates = source.coordinates ;
|
coordinates = source.coordinates ;
|
||||||
frequency = source.frequency ;
|
frequency = source.frequency ;
|
||||||
|
friis_index = source.friis_index ;
|
||||||
|
|
||||||
return *this ;
|
return *this ;
|
||||||
}
|
}
|
||||||
|
@ -29,7 +30,8 @@ bool AccessPoint::operator==(const AccessPoint &source) const
|
||||||
return
|
return
|
||||||
this->WifiDevice::operator==(source) &&
|
this->WifiDevice::operator==(source) &&
|
||||||
coordinates == source.coordinates &&
|
coordinates == source.coordinates &&
|
||||||
frequency == source.frequency ;
|
frequency == source.frequency &&
|
||||||
|
friis_index == source.friis_index ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,6 +41,7 @@ ostream &operator<<(ostream &os, const AccessPoint &ap)
|
||||||
os
|
os
|
||||||
<< "Coordinates: " << ap.coordinates << '\n'
|
<< "Coordinates: " << ap.coordinates << '\n'
|
||||||
<< "Frequency: " << ap.frequency << " Hz" << '\n'
|
<< "Frequency: " << ap.frequency << " Hz" << '\n'
|
||||||
|
<< "Friis index: " << ap.friis_index << '\n'
|
||||||
<< (WifiDevice) ap ;
|
<< (WifiDevice) ap ;
|
||||||
|
|
||||||
return os ;
|
return os ;
|
||||||
|
|
|
@ -14,6 +14,7 @@ class AccessPoint: public WifiDevice
|
||||||
protected:
|
protected:
|
||||||
Point3D coordinates ;
|
Point3D coordinates ;
|
||||||
unsigned long frequency ; ///< Frequency (channel) in Hz
|
unsigned long frequency ; ///< Frequency (channel) in Hz
|
||||||
|
float friis_index ; ///< Friis index used by FBCM
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
@ -26,25 +27,28 @@ public:
|
||||||
AccessPoint(const Point3D &_coordinates = Point3D(),
|
AccessPoint(const Point3D &_coordinates = Point3D(),
|
||||||
const std::string &_ip_addr = "",
|
const std::string &_ip_addr = "",
|
||||||
const std::string &_mac_addr = "",
|
const std::string &_mac_addr = "",
|
||||||
const float &_antenna_gain = AP_DEFAULT_ANTENNA_GAIN,
|
const float _antenna_gain = AP_DEFAULT_ANTENNA_GAIN,
|
||||||
const float &_trx_power = WIFIDEVICE_DEFAULT_TRX_POWER,
|
const float _trx_power = WIFIDEVICE_DEFAULT_TRX_POWER,
|
||||||
const unsigned int &channel = AP_DEFAULT_CHANNEL):
|
const unsigned int &channel = AP_DEFAULT_CHANNEL):
|
||||||
WifiDevice(_ip_addr, _mac_addr, _antenna_gain, _trx_power),
|
WifiDevice(_ip_addr, _mac_addr, _antenna_gain, _trx_power),
|
||||||
coordinates(_coordinates),
|
coordinates(_coordinates),
|
||||||
frequency(PosUtil::wifi_channel_to_hz(channel)) {}
|
frequency(PosUtil::wifi_channel_to_hz(channel)),
|
||||||
|
friis_index(0) {}
|
||||||
|
|
||||||
AccessPoint(const WifiDevice &source,
|
AccessPoint(const WifiDevice &source,
|
||||||
const Point3D &_coordinates,
|
const Point3D &_coordinates,
|
||||||
const unsigned int &channel = AP_DEFAULT_CHANNEL):
|
const unsigned int channel = AP_DEFAULT_CHANNEL):
|
||||||
WifiDevice(source), coordinates(_coordinates),
|
WifiDevice(source), coordinates(_coordinates),
|
||||||
frequency(PosUtil::wifi_channel_to_hz(channel)) {}
|
frequency(PosUtil::wifi_channel_to_hz(channel)),
|
||||||
|
friis_index(0) {}
|
||||||
|
|
||||||
AccessPoint(const WifiDevice &source):
|
AccessPoint(const WifiDevice &source):
|
||||||
WifiDevice(source), coordinates(Point3D()), frequency(0) {}
|
WifiDevice(source), coordinates(Point3D()), frequency(0),
|
||||||
|
friis_index(0) {}
|
||||||
|
|
||||||
AccessPoint(const AccessPoint &source):
|
AccessPoint(const AccessPoint &source):
|
||||||
WifiDevice(source), coordinates(source.coordinates),
|
WifiDevice(source), coordinates(source.coordinates),
|
||||||
frequency(source.frequency) {}
|
frequency(source.frequency), friis_index(0) {}
|
||||||
|
|
||||||
~AccessPoint(void) {}
|
~AccessPoint(void) {}
|
||||||
|
|
||||||
|
@ -52,6 +56,7 @@ public:
|
||||||
//@{
|
//@{
|
||||||
const Point3D& get_coordinates(void) const ;
|
const Point3D& get_coordinates(void) const ;
|
||||||
unsigned long get_frequency(void) const ;
|
unsigned long get_frequency(void) const ;
|
||||||
|
float get_friis_index(void) const ;
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
/** @name Write accessors */
|
/** @name Write accessors */
|
||||||
|
@ -59,6 +64,7 @@ public:
|
||||||
void set_coordinates(const Point3D &_coordinates) ;
|
void set_coordinates(const Point3D &_coordinates) ;
|
||||||
void set_channel(const unsigned int channel) ;
|
void set_channel(const unsigned int channel) ;
|
||||||
void set_frequency(const unsigned long _frequency) ;
|
void set_frequency(const unsigned long _frequency) ;
|
||||||
|
void set_friis_index(const float _friis_index) ;
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
/** @name Operators */
|
/** @name Operators */
|
||||||
|
@ -89,6 +95,12 @@ inline unsigned long AccessPoint::get_frequency() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline float AccessPoint::get_friis_index() const
|
||||||
|
{
|
||||||
|
return friis_index ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* *** Write accessors *** */
|
/* *** Write accessors *** */
|
||||||
|
|
||||||
|
@ -123,6 +135,12 @@ inline void AccessPoint::set_frequency(const unsigned long _frequency)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void AccessPoint::set_friis_index(const float _friis_index)
|
||||||
|
{
|
||||||
|
friis_index = _friis_index ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* *** Operators *** */
|
/* *** Operators *** */
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
#include "fbcm.hh"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
float FBCM::estimate_distance(const Measurement &measurement)
|
||||||
|
{
|
||||||
|
double constant_term = make_constant_term(measurement) ;
|
||||||
|
const float &average_ss = measurement.get_average_ss() ;
|
||||||
|
const AccessPoint *ap = measurement.get_ap() ;
|
||||||
|
return pow(10, (constant_term - average_ss) /
|
||||||
|
(10 * ap->get_friis_index())) ;
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
#ifndef _OWLPS_POSITIONING_FBCM_HH_
|
||||||
|
#define _OWLPS_POSITIONING_FBCM_HH_
|
||||||
|
|
||||||
|
#include "multilaterationalgorithm.hh"
|
||||||
|
|
||||||
|
/// Computes a position using the Interlink Networks formula
|
||||||
|
class FBCM: public MultilaterationAlgorithm
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
FBCM(void) {}
|
||||||
|
~FBCM(void) {}
|
||||||
|
|
||||||
|
float estimate_distance(const Measurement &measurement) ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
#endif // _OWLPS_POSITIONING_FBCM_HH_
|
|
@ -42,6 +42,7 @@ public:
|
||||||
AccessPoint* get_ap() const ;
|
AccessPoint* get_ap() const ;
|
||||||
const std::vector<int>& get_ss_list() const ;
|
const std::vector<int>& get_ss_list() const ;
|
||||||
double get_average_ss() const ;
|
double get_average_ss() const ;
|
||||||
|
int get_ss_list_size() const ;
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
/** @name Write accessors */
|
/** @name Write accessors */
|
||||||
|
@ -100,6 +101,12 @@ inline double Measurement::get_average_ss() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline int Measurement::get_ss_list_size() const
|
||||||
|
{
|
||||||
|
return ss_list.size() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* *** Write accessors *** */
|
/* *** Write accessors *** */
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
#include "positioning.hh"
|
#include "positioning.hh"
|
||||||
#include "realposition.hh"
|
#include "realposition.hh"
|
||||||
#include "radar.hh"
|
#include "fbcm.hh"
|
||||||
#include "interlinknetworks.hh"
|
#include "interlinknetworks.hh"
|
||||||
|
#include "radar.hh"
|
||||||
#include "configuration.hh"
|
#include "configuration.hh"
|
||||||
#include "posexcept.hh"
|
#include "posexcept.hh"
|
||||||
|
#include "stock.hh"
|
||||||
|
|
||||||
using namespace std ;
|
using namespace std ;
|
||||||
|
|
||||||
|
@ -47,6 +49,12 @@ void Positioning::initialise_algorithms()
|
||||||
if (*i == "Real")
|
if (*i == "Real")
|
||||||
algorithms.push_back(new RealPosition) ;
|
algorithms.push_back(new RealPosition) ;
|
||||||
|
|
||||||
|
else if (*i == "FBCM")
|
||||||
|
{
|
||||||
|
Stock::update_all_friis_indexes() ;
|
||||||
|
algorithms.push_back(new FBCM) ;
|
||||||
|
}
|
||||||
|
|
||||||
else if (*i == "InterlinkNetworks")
|
else if (*i == "InterlinkNetworks")
|
||||||
algorithms.push_back(new InterlinkNetworks) ;
|
algorithms.push_back(new InterlinkNetworks) ;
|
||||||
|
|
||||||
|
|
|
@ -153,6 +153,61 @@ const AccessPoint& Stock::find_create_ap(const string &mac)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Stock::update_all_friis_indexes()
|
||||||
|
{
|
||||||
|
for (unordered_map<string, AccessPoint>::iterator ap = aps.begin() ;
|
||||||
|
ap != aps.end() ; ++ap)
|
||||||
|
{
|
||||||
|
string ap_mac = ap->second.get_mac_addr() ;
|
||||||
|
double friis_idx_sum = 0 ;
|
||||||
|
int nb_friis_idx = 0 ;
|
||||||
|
|
||||||
|
// Compute main general term, independant from scans
|
||||||
|
double ap_freq = ap->second.get_frequency() ;
|
||||||
|
double const_term =
|
||||||
|
ap->second.get_antenna_gain()
|
||||||
|
- 20 * log10(4 * M_PI)
|
||||||
|
+ 20 * log10(PosUtil::LIGHT_SPEED / ap_freq)
|
||||||
|
+ ap->second.get_trx_power() ;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Compute an index for each Measurement in each Request in each
|
||||||
|
* ReferencePoint. The Friis index for an AP is the average of all
|
||||||
|
* these indexes.
|
||||||
|
*/
|
||||||
|
for (unordered_set<ReferencePoint>::const_iterator rp =
|
||||||
|
reference_points.begin() ; rp != reference_points.end() ;
|
||||||
|
++rp)
|
||||||
|
{
|
||||||
|
for (vector<CalibrationRequest*>::const_iterator request =
|
||||||
|
rp->get_requests().begin() ;
|
||||||
|
request != rp->get_requests().end() ; ++request)
|
||||||
|
{
|
||||||
|
const unordered_map<string, Measurement> &measurements =
|
||||||
|
(*request)->get_measurements() ;
|
||||||
|
unordered_map<string, Measurement>::const_iterator
|
||||||
|
measurement = measurements.find(ap_mac) ;
|
||||||
|
if (measurement != measurements.end())
|
||||||
|
{
|
||||||
|
double ss = measurement->second.get_average_ss() ;
|
||||||
|
float distance =
|
||||||
|
rp->distance(ap->second.get_coordinates()) ;
|
||||||
|
float mobile_gain =
|
||||||
|
(*request)->get_mobile()->get_antenna_gain() ;
|
||||||
|
friis_idx_sum +=
|
||||||
|
(const_term + mobile_gain - ss)
|
||||||
|
/ (10 * log10(distance)) ;
|
||||||
|
++nb_friis_idx ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nb_friis_idx > 0)
|
||||||
|
ap->second.set_friis_index(friis_idx_sum / nb_friis_idx) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const ReferencePoint& Stock::
|
const ReferencePoint& Stock::
|
||||||
find_create_reference_point(const ReferencePoint &point)
|
find_create_reference_point(const ReferencePoint &point)
|
||||||
{
|
{
|
||||||
|
|
|
@ -64,6 +64,8 @@ public:
|
||||||
static const AccessPoint& find_create_ap(const std::string &mac) ;
|
static const AccessPoint& find_create_ap(const std::string &mac) ;
|
||||||
/// Get a reference to the AccessPoint corresponding to a given MAC address
|
/// Get a reference to the AccessPoint corresponding to a given MAC address
|
||||||
static AccessPoint& getw_ap(const std::string &mac) ;
|
static AccessPoint& getw_ap(const std::string &mac) ;
|
||||||
|
/// Update the friis indexes of all the APs
|
||||||
|
static void update_all_friis_indexes(void) ;
|
||||||
|
|
||||||
/// Look for a ReferencePoint and add it if it does not exist
|
/// Look for a ReferencePoint and add it if it does not exist
|
||||||
static const ReferencePoint&
|
static const ReferencePoint&
|
||||||
|
|
|
@ -171,7 +171,7 @@ void UserInterface::fill_positioning_options()
|
||||||
options.add_options()
|
options.add_options()
|
||||||
("positioning.algorithm,a", po::value< vector<string> >()->composing(),
|
("positioning.algorithm,a", po::value< vector<string> >()->composing(),
|
||||||
"Algorithms used to compute positions. You can specify \
|
"Algorithms used to compute positions. You can specify \
|
||||||
this option more than once (but at least once). Allowed: Real, \
|
this option more than once (but at least once). Allowed: Real, FBCM, \
|
||||||
InterlinkNetworks, RADAR.")
|
InterlinkNetworks, RADAR.")
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
#include <cxxtest/TestSuite.h>
|
||||||
|
|
||||||
|
#include "fbcm.hh"
|
||||||
|
|
||||||
|
class FBCM_test: public CxxTest::TestSuite
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
void test_select_point(void)
|
||||||
|
{
|
||||||
|
MultilaterationAlgorithm *algo = new FBCM() ;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TODO: implement the test.
|
||||||
|
* I was told to accelerate the development, so I leave unneeded unit
|
||||||
|
* tests for later. This tests *is* actually needed, but I did some
|
||||||
|
* result comparison between the old version of OWLPS Positioning and
|
||||||
|
* the current one, and, hm, let's say it's OK for now…
|
||||||
|
*/
|
||||||
|
|
||||||
|
delete algo ;
|
||||||
|
}
|
||||||
|
|
||||||
|
} ;
|
|
@ -101,6 +101,11 @@ public:
|
||||||
element_not_found) ;
|
element_not_found) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_update_all_friis_indexes(void)
|
||||||
|
{
|
||||||
|
// TODO: implement that
|
||||||
|
}
|
||||||
|
|
||||||
void test_reference_points(void)
|
void test_reference_points(void)
|
||||||
{
|
{
|
||||||
ReferencePoint referencepoint1(3,5,7) ;
|
ReferencePoint referencepoint1(3,5,7) ;
|
||||||
|
|
Loading…
Reference in New Issue