[Positioner] Access Point -> Capture Point

Like in the other modules, we get rid of the old use of "access point".
This has user-visible changes, especially in the configuration (the name
of a few options has been changed).
This commit is contained in:
Matteo Cypriani 2013-06-14 15:54:26 -04:00
parent 69cba07122
commit 4ae0874e1f
35 changed files with 467 additions and 466 deletions

View File

@ -31,8 +31,8 @@ endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(OWLPS_POSITIONER_SRC_FILES set(OWLPS_POSITIONER_SRC_FILES
accesspoint.cc capturepoint.cc
accesspointsreadercsv.cc capturepointsreadercsv.cc
area.cc area.cc
autocalibration.cc autocalibration.cc
building.cc building.cc

View File

@ -14,7 +14,7 @@
#include "autocalibration.hh" #include "autocalibration.hh"
#include "accesspoint.hh" #include "capturepoint.hh"
#include "stock.hh" #include "stock.hh"
#include "configuration.hh" #include "configuration.hh"
#include "posexcept.hh" #include "posexcept.hh"
@ -38,11 +38,11 @@ uint32_t Autocalibration::nb_virtual_mobiles = 0 ;
/** /**
* The reference point P we want to generate will end-up containing * The reference point P we want to generate will end-up containing
* as many calibration requests as the total number of APs. * as many calibration requests as the total number of CPs.
* For each of these requests, we consider a transmitter TRX (which is * For each of these requests, we consider a transmitter TRX (which is
* a virtual mobile located in P) and a receiver RX (the current AP). * a virtual mobile located in P) and a receiver RX (the current CP).
* To generate the signal strength (SS) received by RX from TRX, * To generate the signal strength (SS) received by RX from TRX,
* we first select two reference APs REF1 and REF2. Then, we average * we first select two reference CPs REF1 and REF2. Then, we average
* the real measurements REF1->RX and REF2->RX, weighting in function * the real measurements REF1->RX and REF2->RX, weighting in function
* of the angles REF-RX-TRX and the distance from RX to TRX to compute * of the angles REF-RX-TRX and the distance from RX to TRX to compute
* the SS. * the SS.
@ -50,9 +50,9 @@ uint32_t Autocalibration::nb_virtual_mobiles = 0 ;
*/ */
void Autocalibration::generate_reference_point() void Autocalibration::generate_reference_point()
{ {
// If the point is the coordinates of an existing AP, we don't // If the point is the coordinates of an existing CP, we don't
// need to generate it // need to generate it
if (Stock::is_ap_coordinate(point)) if (Stock::is_cp_coordinate(point))
return ; return ;
/* Get/create the reference point */ /* Get/create the reference point */
@ -62,12 +62,12 @@ void Autocalibration::generate_reference_point()
/* Prepare the virtual mobile */ /* Prepare the virtual mobile */
string vmob_mac(PosUtil::int_to_mac(nb_virtual_mobiles++)) ; string vmob_mac(PosUtil::int_to_mac(nb_virtual_mobiles++)) ;
// The gain and trx power of the mobile will be the average of // The gain and trx power of the mobile will be the average of
// those of all the known APs (could be better, probably) // those of all the known CPs (could be better, probably)
vmob_gain = 0 ; vmob_gain = 0 ;
vmob_pow = 0 ; vmob_pow = 0 ;
/* Generate the SS(s) for each AP */ /* Generate the SS(s) for each CP */
for (rx = Stock::aps.begin() ; rx != Stock::aps.end() ; ++rx) for (rx = Stock::cps.begin() ; rx != Stock::cps.end() ; ++rx)
generate_ss() ; generate_ss() ;
assert(! measurements.empty()) ; assert(! measurements.empty()) ;
@ -89,10 +89,10 @@ void Autocalibration::generate_reference_point()
void Autocalibration::generate_ss() void Autocalibration::generate_ss()
{ {
/* Update the mobile's attributes */ /* Update the mobile's attributes */
vmob_gain += rx->second.get_antenna_gain() / Stock::aps.size() ; vmob_gain += rx->second.get_antenna_gain() / Stock::cps.size() ;
vmob_pow += rx->second.get_trx_power() / Stock::aps.size() ; vmob_pow += rx->second.get_trx_power() / Stock::cps.size() ;
/* Skip the RX AP if it is not at the same floor as the point /* Skip the RX CP if it is not at the same floor as the point
* to generate */ * to generate */
const Point3D &rx_coord = rx->second.get_coordinates() ; const Point3D &rx_coord = rx->second.get_coordinates() ;
if (rx_coord.get_z() != point.get_z()) if (rx_coord.get_z() != point.get_z())
@ -105,140 +105,140 @@ void Autocalibration::generate_ss()
if (point.get_y() > rx_coord.get_y()) if (point.get_y() > rx_coord.get_y())
origin_angle = -origin_angle ; origin_angle = -origin_angle ;
/* Choose the nearest AP(s) in angle */ /* Choose the nearest CP(s) in angle */
sort_reference_aps() ; sort_reference_cps() ;
// We need at least one reference AP: // We need at least one reference CP:
if (sorted_negative_angles.empty() && sorted_positive_angles.empty()) if (sorted_negative_angles.empty() && sorted_positive_angles.empty())
throw autocalibration_error("Not enough APs in coverage!") ; throw autocalibration_error("Not enough CPs in coverage!") ;
/* Compute the angle weight of the reference APs */ /* Compute the angle weight of the reference CPs */
weight_aps() ; weight_cps() ;
/* Compute the SS that would be received from a mobile at a /* Compute the SS that would be received from a mobile at a
* distance of RX-P, in the direction of each reference AP */ * distance of RX-P, in the direction of each reference CP */
compute_ss() ; compute_ss() ;
} }
/** /**
* The reference (transmitter) APs are first filtered (floor, coverage), * The reference (transmitter) CPs are first filtered (floor, coverage),
* then sorted according to their angles with RX and P. * then sorted according to their angles with RX and P.
*/ */
void Autocalibration::sort_reference_aps() void Autocalibration::sort_reference_cps()
{ {
const Point3D &rx_coord = rx->second.get_coordinates() ; const Point3D &rx_coord = rx->second.get_coordinates() ;
sorted_negative_angles.clear() ; sorted_negative_angles.clear() ;
sorted_positive_angles.clear() ; sorted_positive_angles.clear() ;
for (unordered_map<string, AccessPoint>::const_iterator for (unordered_map<string, CapturePoint>::const_iterator
ref = Stock::aps.begin() ; ref != Stock::aps.end() ; ++ref) ref = Stock::cps.begin() ; ref != Stock::cps.end() ; ++ref)
{ {
if (ref == rx) if (ref == rx)
continue ; continue ;
/* Skip the AP if it is not at the same floor than the /* Skip the CP if it is not at the same floor than the
* receiver AP */ * receiver CP */
const Point3D &ref_coord = ref->second.get_coordinates() ; const Point3D &ref_coord = ref->second.get_coordinates() ;
if (ref_coord.get_z() != rx_coord.get_z()) if (ref_coord.get_z() != rx_coord.get_z())
continue ; continue ;
/* Skip the AP if it is not in coverage with the receiver AP */ /* Skip the CP if it is not in coverage with the receiver CP */
float coverage = float coverage =
rx->second.received_calibration_from_ap(ref->second) ; rx->second.received_calibration_from_cp(ref->second) ;
if (coverage < 1) // Less than 1% coverage is ridiculous! if (coverage < 1) // Less than 1% coverage is ridiculous!
continue ; continue ;
/* Angle P-RX-REF */ /* Angle P-RX-REF */
double angle = rx_coord.angle_2d(point, ref_coord) ; double angle = rx_coord.angle_2d(point, ref_coord) ;
/* Weight in the APs' list according to coverage and angle */ /* Weight in the CPs' list according to coverage and angle */
double weight = angle / coverage ; double weight = angle / coverage ;
/* Note: this weight is used only to sort the APs, it has nothing /* Note: this weight is used only to sort the CPs, it has nothing
to do with the angle weight (see weight_aps()) used to compute to do with the angle weight (see weight_cps()) used to compute
the SSs. */ the SSs. */
/* Create the list entry */ /* Create the list entry */
pair<double, pair<double,
unordered_map<string, AccessPoint>::const_iterator> unordered_map<string, CapturePoint>::const_iterator>
angle_ap(angle, ref) ; angle_cp(angle, ref) ;
pair<double, pair<double, pair<double, pair<double,
unordered_map<string, AccessPoint>::const_iterator> > unordered_map<string, CapturePoint>::const_iterator> >
weight_angle_ap(weight, angle_ap) ; weight_angle_cp(weight, angle_cp) ;
/* Rotate the AP's coordinates to know the angle direction */ /* Rotate the CP's coordinates to know the angle direction */
Point3D ref_coord_r(ref_coord) ; Point3D ref_coord_r(ref_coord) ;
ref_coord_r.rotate_2d(rx_coord, origin_angle) ; ref_coord_r.rotate_2d(rx_coord, origin_angle) ;
// Insert the AP in the right list, according to the direction: // Insert the CP in the right list, according to the direction:
if (ref_coord_r.get_y() < rx_coord.get_y()) if (ref_coord_r.get_y() < rx_coord.get_y())
sorted_negative_angles.insert(weight_angle_ap) ; sorted_negative_angles.insert(weight_angle_cp) ;
else else
sorted_positive_angles.insert(weight_angle_ap) ; sorted_positive_angles.insert(weight_angle_cp) ;
} }
} }
void Autocalibration::weight_aps() void Autocalibration::weight_cps()
{ {
/* Retrieve the reference APs & angles */ /* Retrieve the reference CPs & angles */
ref_aps.clear() ; ref_cps.clear() ;
map<double, pair<double, map<double, pair<double,
unordered_map<string, AccessPoint>::const_iterator> > unordered_map<string, CapturePoint>::const_iterator> >
::const_iterator s ; ::const_iterator s ;
s = sorted_negative_angles.begin() ; s = sorted_negative_angles.begin() ;
if (s != sorted_negative_angles.end()) if (s != sorted_negative_angles.end())
init_ap(s) ; init_cp(s) ;
s = sorted_positive_angles.begin() ; s = sorted_positive_angles.begin() ;
if (s != sorted_positive_angles.end()) if (s != sorted_positive_angles.end())
init_ap(s) ; init_cp(s) ;
/* Weight the APs */ /* Weight the CPs */
if (ref_aps.size() == 1) if (ref_cps.size() == 1)
ref_aps[0].weight = 100 ; ref_cps[0].weight = 100 ;
else if (ref_aps.size() == 2) else if (ref_cps.size() == 2)
weight_2_aps() ; weight_2_cps() ;
else else
{ {
ostringstream oss ; ostringstream oss ;
oss << "We should not be here... error when sorting the reference" oss << "We should not be here... error when sorting the reference"
<< " APs? (" << ref_aps.size() << " APs sorted)" ; << " CPs? (" << ref_cps.size() << " CPs sorted)" ;
throw autocalibration_error(oss.str()) ; throw autocalibration_error(oss.str()) ;
} }
} }
void Autocalibration::init_ap( void Autocalibration::init_cp(
map<double, pair<double, unordered_map< map<double, pair<double, unordered_map<
string, AccessPoint>::const_iterator> >::const_iterator s) string, CapturePoint>::const_iterator> >::const_iterator s)
{ {
struct ap ref ; struct cp ref ;
ref.ap = &s->second.second->second ; ref.cp = &s->second.second->second ;
ref.angle = s->second.first ; // Angle P-REF-RX ref.angle = s->second.first ; // Angle P-REF-RX
ref_aps.push_back(ref) ; ref_cps.push_back(ref) ;
} }
void Autocalibration::weight_2_aps() void Autocalibration::weight_2_cps()
{ {
assert(ref_aps.size() > 1) ; assert(ref_cps.size() > 1) ;
/* Compute the angle REF1-RX-REF2 */ /* Compute the angle REF1-RX-REF2 */
double reference_angle = ref_aps[0].angle + ref_aps[1].angle ; double reference_angle = ref_cps[0].angle + ref_cps[1].angle ;
/* Note: the reference angle must be the sum of the two angles /* Note: the reference angle must be the sum of the two angles
P-RX-REF1 and P-RX-REF2 instead of simply REF1-RX-REF2, to allow P-RX-REF1 and P-RX-REF2 instead of simply REF1-RX-REF2, to allow
the angle to be within [0;360[° instead of [0;180[°. This is needed the angle to be within [0;360[° instead of [0;180[°. This is needed
if P-RX-REF1 or P-RX-REF2 are greater than 90°, otherwise the if P-RX-REF1 or P-RX-REF2 are greater than 90°, otherwise the
weights would be wrong. */ weights would be wrong. */
/* Weight the two APs */ /* Weight the two CPs */
if (reference_angle == 0) if (reference_angle == 0)
ref_aps[0].weight = ref_aps[1].weight = 50 ; ref_cps[0].weight = ref_cps[1].weight = 50 ;
else else
{ {
ref_aps[0].weight = ref_aps[0].angle * 100 / reference_angle ; ref_cps[0].weight = ref_cps[0].angle * 100 / reference_angle ;
if (ref_aps[0].weight > 100) if (ref_cps[0].weight > 100)
ref_aps[0].weight = 100 ; ref_cps[0].weight = 100 ;
ref_aps[1].weight = 100 - ref_aps[0].weight ; ref_cps[1].weight = 100 - ref_cps[0].weight ;
} }
} }
@ -255,9 +255,9 @@ void Autocalibration::compute_ss()
void Autocalibration::compute_multi_packet_ss() void Autocalibration::compute_multi_packet_ss()
{ {
const ap &ref1 = ref_aps[0] ; const cp &ref1 = ref_cps[0] ;
const ReferencePoint &ref1_rp = const ReferencePoint &ref1_rp =
Stock::get_reference_point(ref1.ap->get_coordinates()) ; Stock::get_reference_point(ref1.cp->get_coordinates()) ;
const vector<CalibrationRequest*> &ref1_cr = const vector<CalibrationRequest*> &ref1_cr =
ref1_rp.get_requests() ; ref1_rp.get_requests() ;
@ -272,7 +272,7 @@ void Autocalibration::compute_multi_packet_ss()
break ; break ;
} }
// The selected reference APs are in coverage of RX, therefore // The selected reference CPs are in coverage of RX, therefore
// we should always find a measurement of RX in ref1_rp // we should always find a measurement of RX in ref1_rp
assert(rx_measurement) ; assert(rx_measurement) ;
@ -286,7 +286,7 @@ void Autocalibration::compute_multi_packet_ss()
if (! packet_generated) if (! packet_generated)
{ {
if (Configuration::is_configured("verbose")) if (Configuration::is_configured("verbose"))
cerr << "No packet has been generated for RX AP " << rx_mac cerr << "No packet has been generated for RX CP " << rx_mac
<< "... failing back to single packet request. Calibration" << "... failing back to single packet request. Calibration"
<< " request involved : " << **cr << "\n" ; << " request involved : " << **cr << "\n" ;
compute_single_packet_ss(0) ; compute_single_packet_ss(0) ;
@ -306,7 +306,7 @@ bool Autocalibration::compute_single_packet_ss(pkt_id_t pkt_id)
/* Compute the consolidated SS */ /* Compute the consolidated SS */
double rx_ss = 0 ; double rx_ss = 0 ;
for (unsigned int i = 0 ; i < ref_aps.size() ; ++i) for (unsigned int i = 0 ; i < ref_cps.size() ; ++i)
{ {
double tmp_ss = compute_weighted_ss(i, pkt_id, point_dst) ; double tmp_ss = compute_weighted_ss(i, pkt_id, point_dst) ;
if (tmp_ss > 0) // error if (tmp_ss > 0) // error
@ -324,14 +324,14 @@ bool Autocalibration::compute_single_packet_ss(pkt_id_t pkt_id)
measurements[rx_mac].add_ss(pkt_id, rx_ss) ; measurements[rx_mac].add_ss(pkt_id, rx_ss) ;
// Useful only if the measurement was just created, but it is not // Useful only if the measurement was just created, but it is not
// worth a test: // worth a test:
measurements[rx_mac].set_ap(&rx->second) ; measurements[rx_mac].set_cp(&rx->second) ;
return true ; return true ;
} }
/** /**
* @param ap_idx The index of the AP in #ref_aps. * @param cp_idx The index of the CP in #ref_cps.
* @param pkt_id The number of the packet to generate, or 0 if we * @param pkt_id The number of the packet to generate, or 0 if we
* generate only one packet per reference point. * generate only one packet per reference point.
* @param point_dst The distance RX-P. * @param point_dst The distance RX-P.
@ -339,20 +339,20 @@ bool Autocalibration::compute_single_packet_ss(pkt_id_t pkt_id)
* @returns The weighted SS value in dBm, or 1 in case of error. * @returns The weighted SS value in dBm, or 1 in case of error.
*/ */
double Autocalibration::compute_weighted_ss( double Autocalibration::compute_weighted_ss(
unsigned int ap_idx, pkt_id_t pkt_id, float point_dst) unsigned int cp_idx, pkt_id_t pkt_id, float point_dst)
{ {
const ap &ref = ref_aps[ap_idx] ; const cp &ref = ref_cps[cp_idx] ;
const ReferencePoint &rp = const ReferencePoint &rp =
Stock::get_reference_point(ref.ap->get_coordinates()) ; Stock::get_reference_point(ref.cp->get_coordinates()) ;
/* Friis index */ /* Friis index */
const string &rx_mac = rx->second.get_mac_addr() ; const string &rx_mac = rx->second.get_mac_addr() ;
float friis_idx ; float friis_idx ;
if (pkt_id == 0) if (pkt_id == 0)
friis_idx = rp.friis_index_for_ap(rx_mac) ; friis_idx = rp.friis_index_for_cp(rx_mac) ;
else else
{ {
friis_idx = rp.friis_index_for_ap(rx_mac, pkt_id) ; friis_idx = rp.friis_index_for_cp(rx_mac, pkt_id) ;
if (friis_idx == 0) if (friis_idx == 0)
return 1 ; // The packet pkt_id does not exist in rp return 1 ; // The packet pkt_id does not exist in rp
} }
@ -362,8 +362,8 @@ double Autocalibration::compute_weighted_ss(
double common_ss = rx->second.friis_constant_term() ; double common_ss = rx->second.friis_constant_term() ;
double ss = double ss =
common_ss + common_ss +
ref.ap->get_trx_power() + ref.cp->get_trx_power() +
ref.ap->get_antenna_gain() - ref.cp->get_antenna_gain() -
10 * friis_idx * log10(point_dst) ; 10 * friis_idx * log10(point_dst) ;
return ss * ref.weight / 100 ; return ss * ref.weight / 100 ;

View File

@ -15,7 +15,7 @@
#ifndef _OWLPS_POSITIONING_AUTOCALIBRATION_HH_ #ifndef _OWLPS_POSITIONING_AUTOCALIBRATION_HH_
#define _OWLPS_POSITIONING_AUTOCALIBRATION_HH_ #define _OWLPS_POSITIONING_AUTOCALIBRATION_HH_
class AccessPoint ; class CapturePoint ;
class Point3D ; class Point3D ;
#include "measurement.hh" #include "measurement.hh"
@ -30,20 +30,20 @@ class Point3D ;
class Autocalibration class Autocalibration
{ {
private: private:
struct ap struct cp
{ {
const AccessPoint *ap ; const CapturePoint *cp ;
float weight ; // Weight of the AP in percents float weight ; // Weight of the CP in percents
float angle ; float angle ;
} ; } ;
/// Current AP to generate a SS for /// Current CP to generate a SS for
std::unordered_map<std::string, AccessPoint>::const_iterator rx ; std::unordered_map<std::string, CapturePoint>::const_iterator rx ;
/// Angle P-RX-O, O being the origin of the trigonometric circle /// Angle P-RX-O, O being the origin of the trigonometric circle
float origin_angle ; float origin_angle ;
/// Selected transmitter APs /// Selected transmitter CPs
std::vector<ap> ref_aps ; std::vector<cp> ref_cps ;
/// Angles of the transmitter APs (before M on the trigonometric /// Angles of the transmitter CPs (before M on the trigonometric
/// circle) /// circle)
/** /**
* Note that the angles are stored in absolute value. * Note that the angles are stored in absolute value.
@ -51,13 +51,13 @@ private:
std::multimap<double, std::multimap<double,
std::pair<double, std::pair<double,
std::unordered_map< std::unordered_map<
std::string, AccessPoint>::const_iterator> > std::string, CapturePoint>::const_iterator> >
sorted_negative_angles ; sorted_negative_angles ;
/// Angles of the transmitter APs (after M on the trigonometric circle) /// Angles of the transmitter CPs (after M on the trigonometric circle)
std::multimap<double, std::multimap<double,
std::pair<double, std::pair<double,
std::unordered_map< std::unordered_map<
std::string, AccessPoint>::const_iterator> > std::string, CapturePoint>::const_iterator> >
sorted_positive_angles ; sorted_positive_angles ;
/// Characteristics of the virtual mobile /// Characteristics of the virtual mobile
double vmob_gain, vmob_pow ; double vmob_gain, vmob_pow ;
@ -71,26 +71,26 @@ protected:
/// The coordinates of the reference point to generate /// The coordinates of the reference point to generate
const Point3D &point ; const Point3D &point ;
/// Generates the SSs for all the APs /// Generates the SSs for all the CPs
void generate_ss(void) ; void generate_ss(void) ;
/// Sorts the reference APs for a receiver AP /// Sorts the reference CPs for a receiver CP
void sort_reference_aps(void) ; void sort_reference_cps(void) ;
/// Computes the weight of the selected AP(s) /// Computes the weight of the selected CP(s)
void weight_aps(void) ; void weight_cps(void) ;
void init_ap( void init_cp(
std::map<double, std::pair<double, std::unordered_map< std::map<double, std::pair<double, std::unordered_map<
std::string, AccessPoint>::const_iterator> >::const_iterator s) ; std::string, CapturePoint>::const_iterator> >::const_iterator s) ;
/// Weights two APs according to their angles /// Weights two CPs according to their angles
void weight_2_aps(void) ; void weight_2_cps(void) ;
/// Computes the SS of the virtual mobile /// Computes the SS of the virtual mobile
void compute_ss(void) ; void compute_ss(void) ;
/// Computes a SS with several packets in it /// Computes a SS with several packets in it
void compute_multi_packet_ss(void) ; void compute_multi_packet_ss(void) ;
/// Computes a SS with only one packet in it /// Computes a SS with only one packet in it
bool compute_single_packet_ss(pkt_id_t pkt_id) ; bool compute_single_packet_ss(pkt_id_t pkt_id) ;
/// Computes a SS according to the weight of the AP /// Computes a SS according to the weight of the CP
double compute_weighted_ss( double compute_weighted_ss(
unsigned int ap_idx, pkt_id_t pkt_id, float point_dst) ; unsigned int cp_idx, pkt_id_t pkt_id, float point_dst) ;
public: public:
Autocalibration(const Point3D &_point): point(_point) {} Autocalibration(const Point3D &_point): point(_point) {}
@ -100,3 +100,4 @@ public:
} ; } ;
#endif // _OWLPS_POSITIONING_AUTOCALIBRATION_HH_ #endif // _OWLPS_POSITIONING_AUTOCALIBRATION_HH_

View File

@ -12,7 +12,7 @@
*/ */
#include "accesspoint.hh" #include "capturepoint.hh"
#include "stock.hh" #include "stock.hh"
#include "posexcept.hh" #include "posexcept.hh"
@ -23,7 +23,7 @@ using namespace std ;
/* *** Operations *** */ /* *** Operations *** */
double AccessPoint::friis_constant_term() const double CapturePoint::friis_constant_term() const
{ {
double wavelength = double wavelength =
static_cast<double>(PosUtil::LIGHT_SPEED) / frequency ; static_cast<double>(PosUtil::LIGHT_SPEED) / frequency ;
@ -32,18 +32,18 @@ double AccessPoint::friis_constant_term() const
/** /**
* @param trx The transmitter AP. * @param trx The transmitter CP.
* @returns The percentage of calibration packets sent by `trx` and * @returns The percentage of calibration packets sent by `trx` and
* received by the AP. * received by the CP.
* @returns 0 if no packet were received from `trx.` * @returns 0 if no packet were received from `trx.`
*/ */
float AccessPoint:: float CapturePoint::
received_calibration_from_ap(const AccessPoint &trx) const received_calibration_from_cp(const CapturePoint &trx) const
{ {
if (this == &trx) if (this == &trx)
return 100 ; return 100 ;
// If no reference point is associated with trx, no AP received // If no reference point is associated with trx, no CP received
// any calibration from it: // any calibration from it:
const ReferencePoint *ref_trx ; const ReferencePoint *ref_trx ;
try try
@ -62,7 +62,7 @@ received_calibration_from_ap(const AccessPoint &trx) const
return 0 ; return 0 ;
// Count the number of messages sent by trx and the number of // Count the number of messages sent by trx and the number of
// messages actually received by the AP: // messages actually received by the CP:
unsigned int unsigned int
received_packets = 0, received_packets = 0,
expected_packets = 0 ; expected_packets = 0 ;
@ -90,7 +90,7 @@ received_calibration_from_ap(const AccessPoint &trx) const
/* *** Operators *** */ /* *** Operators *** */
AccessPoint& AccessPoint::operator=(const AccessPoint &source) CapturePoint& CapturePoint::operator=(const CapturePoint &source)
{ {
if (this == &source) if (this == &source)
return *this ; return *this ;
@ -104,7 +104,7 @@ AccessPoint& AccessPoint::operator=(const AccessPoint &source)
} }
bool AccessPoint::operator==(const AccessPoint &source) const bool CapturePoint::operator==(const CapturePoint &source) const
{ {
if (this == &source) if (this == &source)
return true ; return true ;
@ -118,13 +118,13 @@ bool AccessPoint::operator==(const AccessPoint &source) const
ostream &operator<<(ostream &os, const AccessPoint &ap) ostream &operator<<(ostream &os, const CapturePoint &cp)
{ {
os os
<< "Coordinates: " << ap.coordinates << '\n' << "Coordinates: " << cp.coordinates << '\n'
<< "Frequency: " << ap.frequency << " Hz" << '\n' << "Frequency: " << cp.frequency << " Hz" << '\n'
<< "Friis index: " << ap.friis_index << '\n' << "Friis index: " << cp.friis_index << '\n'
<< (WifiDevice) ap ; << (WifiDevice) cp ;
return os ; return os ;
} }

View File

@ -19,12 +19,12 @@
#include "point3d.hh" #include "point3d.hh"
#include "posutil.hh" #include "posutil.hh"
#define AP_DEFAULT_CHANNEL 6 #define CP_DEFAULT_CHANNEL 6
#define AP_DEFAULT_ANTENNA_GAIN 5 #define CP_DEFAULT_ANTENNA_GAIN 5
/// Represents a [Wi-Fi device](@ref WifiDevice) used for capturing /// Represents a [Wi-Fi device](@ref WifiDevice) used for capturing
/// requests /// requests
class AccessPoint: public WifiDevice class CapturePoint: public WifiDevice
{ {
protected: protected:
Point3D coordinates ; Point3D coordinates ;
@ -36,36 +36,36 @@ public:
* Special parameters: * Special parameters:
* - `_antenna_gain` Antenna gain in dBi. * - `_antenna_gain` Antenna gain in dBi.
* - `_trx_power` Transmit power in dBm. * - `_trx_power` Transmit power in dBm.
* - `channel` Wi-Fi channel the AP is listening to (integer * - `channel` Wi-Fi channel the CP is listening to (integer
* between 1 and 14). It will be converted to a frequency in Hz. * between 1 and 14). It will be converted to a frequency in Hz.
*/ */
AccessPoint(const Point3D &_coordinates = Point3D(), CapturePoint(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 = CP_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 = CP_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) {} friis_index(0) {}
AccessPoint(const WifiDevice &source, CapturePoint(const WifiDevice &source,
const Point3D &_coordinates, const Point3D &_coordinates,
const unsigned int channel = AP_DEFAULT_CHANNEL): const unsigned int channel = CP_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) {} friis_index(0) {}
AccessPoint(const WifiDevice &source): CapturePoint(const WifiDevice &source):
WifiDevice(source), coordinates(Point3D()), frequency(0), WifiDevice(source), coordinates(Point3D()), frequency(0),
friis_index(0) {} friis_index(0) {}
AccessPoint(const AccessPoint &source): CapturePoint(const CapturePoint &source):
WifiDevice(source), coordinates(source.coordinates), WifiDevice(source), coordinates(source.coordinates),
frequency(source.frequency), friis_index(0) {} frequency(source.frequency), friis_index(0) {}
~AccessPoint(void) {} ~CapturePoint(void) {}
/** @name Read accessors */ /** @name Read accessors */
//@{ //@{
@ -87,19 +87,19 @@ public:
/// Returns the Friis formula's constant term /// Returns the Friis formula's constant term
double friis_constant_term(void) const ; double friis_constant_term(void) const ;
/// Computes the percentage of the calibration packets from `trx` /// Computes the percentage of the calibration packets from `trx`
/// received by the AP /// received by the CP
float received_calibration_from_ap(const AccessPoint &trx) const ; float received_calibration_from_cp(const CapturePoint &trx) const ;
//@} //@}
/** @name Operators */ /** @name Operators */
//@{ //@{
AccessPoint& operator=(const AccessPoint &source) ; CapturePoint& operator=(const CapturePoint &source) ;
bool operator==(const AccessPoint &source) const ; bool operator==(const CapturePoint &source) const ;
bool operator!=(const AccessPoint &source) const ; bool operator!=(const CapturePoint &source) const ;
//@} //@}
/// Displays an AccessPoint /// Displays a CapturePoint
friend std::ostream &operator<<(std::ostream &os, const AccessPoint &ap) ; friend std::ostream &operator<<(std::ostream &os, const CapturePoint &cp) ;
} ; } ;
@ -107,19 +107,19 @@ public:
/* *** Read accessors *** */ /* *** Read accessors *** */
inline const Point3D& AccessPoint::get_coordinates() const inline const Point3D& CapturePoint::get_coordinates() const
{ {
return coordinates ; return coordinates ;
} }
inline unsigned long AccessPoint::get_frequency() const inline unsigned long CapturePoint::get_frequency() const
{ {
return frequency ; return frequency ;
} }
inline float AccessPoint::get_friis_index() const inline float CapturePoint::get_friis_index() const
{ {
return friis_index ; return friis_index ;
} }
@ -129,7 +129,7 @@ inline float AccessPoint::get_friis_index() const
/* *** Write accessors *** */ /* *** Write accessors *** */
inline void AccessPoint::set_coordinates(const Point3D &_coordinates) inline void CapturePoint::set_coordinates(const Point3D &_coordinates)
{ {
coordinates = _coordinates ; coordinates = _coordinates ;
} }
@ -140,7 +140,7 @@ inline void AccessPoint::set_coordinates(const Point3D &_coordinates)
* be converted into a frequency in Hz and affected to #frequency. If * be converted into a frequency in Hz and affected to #frequency. If
* it is not a Wi-Fi channel number, 0 will be affected to #frequency. * it is not a Wi-Fi channel number, 0 will be affected to #frequency.
*/ */
inline void AccessPoint::set_channel(const unsigned int channel) inline void CapturePoint::set_channel(const unsigned int channel)
{ {
set_frequency(PosUtil::wifi_channel_to_hz(channel)) ; set_frequency(PosUtil::wifi_channel_to_hz(channel)) ;
} }
@ -153,13 +153,13 @@ inline void AccessPoint::set_channel(const unsigned int channel)
* Note that set_channel() is more secure because a wrong channel * Note that set_channel() is more secure because a wrong channel
* number will cause #frequency to be set to zero. * number will cause #frequency to be set to zero.
*/ */
inline void AccessPoint::set_frequency(const unsigned long _frequency) inline void CapturePoint::set_frequency(const unsigned long _frequency)
{ {
frequency = _frequency ; frequency = _frequency ;
} }
inline void AccessPoint::set_friis_index(const float _friis_index) inline void CapturePoint::set_friis_index(const float _friis_index)
{ {
friis_index = _friis_index ; friis_index = _friis_index ;
} }
@ -169,7 +169,7 @@ inline void AccessPoint::set_friis_index(const float _friis_index)
/* *** Operators *** */ /* *** Operators *** */
inline bool AccessPoint::operator!=(const AccessPoint &source) const inline bool CapturePoint::operator!=(const CapturePoint &source) const
{ {
return !(*this == source) ; return !(*this == source) ;
} }

View File

@ -12,7 +12,7 @@
*/ */
#include "accesspointsreadercsv.hh" #include "capturepointsreadercsv.hh"
#include "point3d.hh" #include "point3d.hh"
#include "stock.hh" #include "stock.hh"
#include "posexcept.hh" #include "posexcept.hh"
@ -24,7 +24,7 @@ using namespace std ;
/* *** Constructors *** */ /* *** Constructors *** */
AccessPointsReaderCSV::AccessPointsReaderCSV(const string &file_name): CapturePointsReaderCSV::CapturePointsReaderCSV(const string &file_name):
file(file_name) file(file_name)
{ {
read_devices() ; read_devices() ;
@ -35,38 +35,38 @@ AccessPointsReaderCSV::AccessPointsReaderCSV(const string &file_name):
/* *** Operations *** */ /* *** Operations *** */
void AccessPointsReaderCSV::read_devices() void CapturePointsReaderCSV::read_devices()
{ {
while (file.next_line()) while (file.next_line())
process_device_line() ; process_device_line() ;
} }
void AccessPointsReaderCSV::process_device_line() void CapturePointsReaderCSV::process_device_line()
{ {
string mac ; string mac ;
if (! file.read_field(mac)) if (! file.read_field(mac))
throw malformed_input_data("Cannot read access point MAC address!") ; throw malformed_input_data("Cannot read capture point MAC address!") ;
PosUtil::to_upper(mac) ; PosUtil::to_upper(mac) ;
Point3D coord ; Point3D coord ;
if (! file.read_point3d(coord)) if (! file.read_point3d(coord))
throw malformed_input_data("Cannot read access point coordinates!") ; throw malformed_input_data("Cannot read capture point coordinates!") ;
unsigned long frequency ; unsigned long frequency ;
if (! file.read_field(frequency)) if (! file.read_field(frequency))
throw malformed_input_data("Cannot read access point frequency!") ; throw malformed_input_data("Cannot read capture point frequency!") ;
float gain ; float gain ;
if (! file.read_field(gain)) if (! file.read_field(gain))
throw malformed_input_data("Cannot read access point gain!") ; throw malformed_input_data("Cannot read capture point gain!") ;
float power ; float power ;
if (! file.read_field(power)) if (! file.read_field(power))
throw malformed_input_data("Cannot read access point power!") ; throw malformed_input_data("Cannot read capture point power!") ;
string ip("") ; string ip("") ;
AccessPoint device(coord, ip, mac, gain, power, frequency) ; CapturePoint device(coord, ip, mac, gain, power, frequency) ;
Stock::find_create_ap(device) ; Stock::find_create_cp(device) ;
} }

View File

@ -21,12 +21,12 @@ class Point3D ;
#include <string> #include <string>
/// Reads and registers to the Stock AccessPoint list from CSV files /// Reads and registers to the Stock CapturePoint list from CSV files
/** /**
* CSV format for access points is: * CSV format for capture points is:
* MAC;X;Y;Z;Frequency_Hz;Antenna_gain_dBi;Trx_power_dBm * MAC;X;Y;Z;Frequency_Hz;Antenna_gain_dBi;Trx_power_dBm
*/ */
class AccessPointsReaderCSV class CapturePointsReaderCSV
{ {
protected: protected:
CSVFileReader file ; CSVFileReader file ;
@ -35,9 +35,9 @@ protected:
void process_device_line(void) ; void process_device_line(void) ;
public: public:
AccessPointsReaderCSV(const std::string &file_name) ; CapturePointsReaderCSV(const std::string &file_name) ;
~AccessPointsReaderCSV(void) {} ~CapturePointsReaderCSV(void) {}
} ; } ;
#endif // _OWLPS_POSITIONING_ACCESSPOINTSREADERCSV_HH_ #endif // _OWLPS_POSITIONING_ACCESSPOINTSREADERCSV_HH_

View File

@ -1,4 +1,4 @@
# Listeners' physical description file. # Capture points' (listeners') physical description file.
# #
# Each line follows this format: # Each line follows this format:
# MAC address;X;Y;Z;Channel (Hz);Antenna gain (dBi);Trx power (dBm) # MAC address;X;Y;Z;Channel (Hz);Antenna gain (dBi);Trx power (dBm)

1 # Listeners' physical description file. # Capture points' (listeners') physical description file.
2 #
3 # Each line follows this format:
4 # MAC address;X;Y;Z;Channel (Hz);Antenna gain (dBi);Trx power (dBm)

View File

@ -21,9 +21,9 @@
# The options in this section are related to the data that are read # The options in this section are related to the data that are read
# when the program starts. # when the program starts.
# Description of the machines running the listeners. # Description of the machines running the listeners (capture points).
ap-medium = CSV cp-medium = CSV
ap-csv-file = /usr/local/etc/owlps/listeners.csv cp-csv-file = /usr/local/etc/owlps/listeners.csv
# Description of the clients # Description of the clients
mobile-medium = CSV mobile-medium = CSV
@ -80,18 +80,18 @@ mobile-csv-file = /usr/local/etc/owlps/mobiles.csv
# It is unactivated by default, mainly to avoid interferent devices. # It is unactivated by default, mainly to avoid interferent devices.
#accept-new-mobiles = false #accept-new-mobiles = false
# This option allows to create a new AP when a request is captured by an # This option allows to create a new capture point (CP) when a request
# AP which is not currently in the APs' list (i.e. not declared in the # is captured by a CP which is not currently in the CPs' list (i.e. not
# APs' configuration file), or when a self-calibration request is sent # declared in the CPs' configuration file), or when a self-calibration
# by an unknown AP. # request is sent by an unknown CP.
# It is unactivated by default for the sake of security. # It is unactivated by default for the sake of security.
#accept-new-aps = false #accept-new-cps = false
# When receiving a calibration or autocalibration request from an AP, # When receiving a calibration or autocalibration request from a CP,
# containing the transmiter's coordinates, memorise the new AP's # containing the transmiter's coordinates, memorise the new CP's
# coordinates. # coordinates.
# This is unactivated by default for the sake of security. # This is unactivated by default for the sake of security.
#update-ap-coordinates-online = false #update-cp-coordinates-online = false
# Coordinates of the deployment area. # Coordinates of the deployment area.
# This is used to delimit the area in which reference points are # This is used to delimit the area in which reference points are
@ -129,8 +129,8 @@ mobile-csv-file = /usr/local/etc/owlps/mobiles.csv
#ss-similarity = interval2 #ss-similarity = interval2
# Smallest possible value for a received signal strength, in dBm. This # Smallest possible value for a received signal strength, in dBm. This
# depends on the sensibility of the APs' Wi-Fi hardware. It is used to # depends on the sensibility of the CPs' Wi-Fi hardware. It is used to
# compensate for APs that are not in coverage in a given measurement. # compensate for CPs that are not in coverage in a given measurement.
# The default value is -99 dBm, which should be fine in most cases. # The default value is -99 dBm, which should be fine in most cases.
#smallest-ss = -99 #smallest-ss = -99
@ -213,12 +213,12 @@ mobile-csv-file = /usr/local/etc/owlps/mobiles.csv
# directly to each calibration request. # directly to each calibration request.
#average-reference-points = false #average-reference-points = false
# Do not select reference points on which an AP is sit, as far as # Do not select reference points on which a CP is sit, as far as
# possible (i.e. if there are reference points where no AP sits). # possible (i.e. if there are reference points where no CP sits).
# This is useful if you are using autocalibration and want to select # This is useful if you are using autocalibration and want to select
# only the generated reference points. # only the generated reference points.
# The default is false. # The default is false.
#ignore-ap-reference-points = false #ignore-cp-reference-points = false
[output] [output]
# The following options are related to the output of the results. # The following options are related to the output of the results.

View File

@ -32,13 +32,13 @@ float FBCM::estimate_distance(const Measurement &measurement)
{ {
double constant_term = make_constant_term(measurement) ; double constant_term = make_constant_term(measurement) ;
const float &average_dbm = measurement.get_average_dbm() ; const float &average_dbm = measurement.get_average_dbm() ;
const AccessPoint *ap = measurement.get_ap() ; const CapturePoint *cp = measurement.get_cp() ;
return pow(10, (constant_term - average_dbm) / return pow(10, (constant_term - average_dbm) /
(10 * friis_index(ap))) ; (10 * friis_index(cp))) ;
} }
inline float FBCM::friis_index(const AccessPoint *const ap) const inline float FBCM::friis_index(const CapturePoint *const cp) const
{ {
return ap->get_friis_index() ; return cp->get_friis_index() ;
} }

View File

@ -21,7 +21,7 @@
class FBCM: public TrilaterationAlgorithm class FBCM: public TrilaterationAlgorithm
{ {
protected: protected:
float friis_index(const AccessPoint *const ap) const ; float friis_index(const CapturePoint *const cp) const ;
public: public:
FBCM(void): PositioningAlgorithm("FBCM") {} FBCM(void): PositioningAlgorithm("FBCM") {}

View File

@ -23,7 +23,7 @@ Result FRBHMBasic::compute(const Request &_request)
// Select the closest point in SS // Select the closest point in SS
closest_in_ss = &select_point(_request) ; closest_in_ss = &select_point(_request) ;
compute_ap_distance_circles() ; compute_cp_distance_circles() ;
Point3D position(trilaterate_2d(closest_in_ss->get_z())) ; Point3D position(trilaterate_2d(closest_in_ss->get_z())) ;
return Result(request, name, position) ; return Result(request, name, position) ;
@ -40,13 +40,13 @@ float FRBHMBasic::estimate_distance(const Measurement &measurement)
{ {
double constant_term = make_constant_term(measurement) ; double constant_term = make_constant_term(measurement) ;
const float &average_dbm = measurement.get_average_dbm() ; const float &average_dbm = measurement.get_average_dbm() ;
const AccessPoint *ap = measurement.get_ap() ; const CapturePoint *cp = measurement.get_cp() ;
return pow(10, (constant_term - average_dbm) / return pow(10, (constant_term - average_dbm) /
(10 * friis_index(ap))) ; (10 * friis_index(cp))) ;
} }
inline float FRBHMBasic::friis_index(const AccessPoint *const ap) const inline float FRBHMBasic::friis_index(const CapturePoint *const cp) const
{ {
return closest_in_ss->friis_index_for_ap(ap->get_mac_addr()) ; return closest_in_ss->friis_index_for_cp(cp->get_mac_addr()) ;
} }

View File

@ -24,7 +24,7 @@ class FRBHMBasic: public FBCM, public NSS
protected: protected:
ReferencePoint const *closest_in_ss ; ReferencePoint const *closest_in_ss ;
float friis_index(const AccessPoint *const ap) const ; float friis_index(const CapturePoint *const cp) const ;
public: public:
FRBHMBasic(void): FRBHMBasic(void):

View File

@ -124,12 +124,12 @@ bool InputCSV::fill_current_request()
if (direction_int != 0) if (direction_int != 0)
direction = direction_int ; direction = direction_int ;
/* Read all the {AP_MAC;Packet_ID;SS} */ /* Read all the {CP_MAC;Packet_ID;SS} */
unordered_map<string, Measurement> measurements ; unordered_map<string, Measurement> measurements ;
string mac_ap ; string mac_cp ;
while (file.read_field(mac_ap)) while (file.read_field(mac_cp))
{ {
pkt_id_t packet_id ; pkt_id_t packet_id ;
if (! read_field(packet_id, "the packet ID")) if (! read_field(packet_id, "the packet ID"))
@ -139,14 +139,14 @@ bool InputCSV::fill_current_request()
if (! read_field(ss, "the signal strength")) if (! read_field(ss, "the signal strength"))
return false ; return false ;
PosUtil::to_upper(mac_ap) ; PosUtil::to_upper(mac_cp) ;
if (! Configuration::bool_value("positioning.accept-new-aps") && if (! Configuration::bool_value("positioning.accept-new-cps") &&
! Stock::ap_exists(mac_ap)) ! Stock::cp_exists(mac_cp))
continue ; continue ;
const AccessPoint &ap = Stock::find_create_ap(mac_ap) ; const CapturePoint &cp = Stock::find_create_cp(mac_cp) ;
measurements[mac_ap].set_ap(&ap) ; measurements[mac_cp].set_cp(&cp) ;
measurements[mac_ap].add_ss(packet_id, ss) ; measurements[mac_cp].add_ss(packet_id, ss) ;
} }
if (measurements.empty()) if (measurements.empty())
return false ; return false ;

View File

@ -26,8 +26,8 @@
/** /**
* CSV format is: * CSV format is:
* Format_version;Mobile_MAC;Request_type;Number_of_packets; * Format_version;Mobile_MAC;Request_type;Number_of_packets;
* Timestamp;X;Y;Z;Direction;AP_MAC_1;Packet_ID_1;SS_1;; * Timestamp;X;Y;Z;Direction;CP_MAC_1;Packet_ID_1;SS_1;;
* AP_MAC_n;Packet_ID_n;SS_n * CP_MAC_n;Packet_ID_n;SS_n
*/ */
class InputCSV: public InputMedium class InputCSV: public InputMedium
{ {

View File

@ -13,7 +13,7 @@
#include "inputdatareader.hh" #include "inputdatareader.hh"
#include "accesspointsreadercsv.hh" #include "capturepointsreadercsv.hh"
#include "mobilesreadercsv.hh" #include "mobilesreadercsv.hh"
#include "topologyreadercsv.hh" #include "topologyreadercsv.hh"
#include "inputcsv.hh" #include "inputcsv.hh"
@ -56,20 +56,20 @@ InputDataReader::~InputDataReader()
void InputDataReader::read_access_points() void InputDataReader::read_access_points()
{ {
if (! Configuration::is_configured("data-input.ap-medium")) if (! Configuration::is_configured("data-input.cp-medium"))
return ; return ;
initialise_access_points_media() ; initialise_access_points_media() ;
if (Configuration::is_configured("verbose")) if (Configuration::is_configured("verbose"))
cerr << Stock::nb_aps() << " access points stored.\n" ; cerr << Stock::nb_cps() << " capture points stored.\n" ;
} }
void InputDataReader::initialise_access_points_media() void InputDataReader::initialise_access_points_media()
{ {
const vector<string> &media_names = const vector<string> &media_names =
Configuration::string_vector_value("data-input.ap-medium") ; Configuration::string_vector_value("data-input.cp-medium") ;
for (vector<string>::const_iterator i = media_names.begin() ; for (vector<string>::const_iterator i = media_names.begin() ;
i != media_names.end() ; ++i) i != media_names.end() ; ++i)
@ -86,12 +86,12 @@ void InputDataReader::initialise_access_points_media()
void InputDataReader::initialise_access_points_csv() void InputDataReader::initialise_access_points_csv()
{ {
if (! Configuration::is_configured("data-input.ap-csv-file")) if (! Configuration::is_configured("data-input.cp-csv-file"))
throw missing_configuration( throw missing_configuration(
"No input CSV file specified for access points") ; "No input CSV file specified for capture points") ;
AccessPointsReaderCSV( CapturePointsReaderCSV(
Configuration::string_value("data-input.ap-csv-file")) ; Configuration::string_value("data-input.cp-csv-file")) ;
} }

View File

@ -100,30 +100,30 @@ fill_calibration_request_data(const string &mac_mobile, Point3D &position,
if (position) if (position)
{ {
// Update the AP's coordinates if allowed (and if the mobile is // Update the CP's coordinates if allowed (and if the mobile is
// an AP, of course) // a CP, of course)
if (Configuration:: if (Configuration::
bool_value("positioning.update-ap-coordinates-online")) bool_value("positioning.update-cp-coordinates-online"))
{ {
if (type == OWL_REQUEST_AUTOCALIBRATION && if (type == OWL_REQUEST_AUTOCALIBRATION &&
Configuration::bool_value("positioning.accept-new-aps")) Configuration::bool_value("positioning.accept-new-cps"))
{ {
AccessPoint &transmitter = CapturePoint &transmitter =
const_cast<AccessPoint&>( const_cast<CapturePoint&>(
Stock::find_create_ap(mac_mobile)) ; Stock::find_create_cp(mac_mobile)) ;
transmitter.set_coordinates(position) ; transmitter.set_coordinates(position) ;
} }
else else
{ {
try try
{ {
AccessPoint &transmitter = CapturePoint &transmitter =
const_cast<AccessPoint&>(Stock::get_ap(mac_mobile)) ; const_cast<CapturePoint&>(Stock::get_cp(mac_mobile)) ;
transmitter.set_coordinates(position) ; transmitter.set_coordinates(position) ;
} }
catch (element_not_found &e) catch (element_not_found &e)
{ {
// The mobile is not an AP or the AP does not exist // The mobile is not a CP or the CP does not exist
} }
} }
} }
@ -132,17 +132,17 @@ fill_calibration_request_data(const string &mac_mobile, Point3D &position,
else if (type == OWL_REQUEST_AUTOCALIBRATION) else if (type == OWL_REQUEST_AUTOCALIBRATION)
{ {
// If an autocalibration request does not contain the coordinates // If an autocalibration request does not contain the coordinates
// of the AP, we use the current coordinates of the AP as // of the CP, we use the current coordinates of the CP as
// ReferencePoint. // ReferencePoint.
try try
{ {
AccessPoint &transmitter = CapturePoint &transmitter =
const_cast<AccessPoint&>(Stock::get_ap(mac_mobile)) ; const_cast<CapturePoint&>(Stock::get_cp(mac_mobile)) ;
position = transmitter.get_coordinates() ; position = transmitter.get_coordinates() ;
} }
catch (element_not_found &e) catch (element_not_found &e)
{ {
// The mobile is not an AP or the AP does not exist // The mobile is not a CP or the CP does not exist
} }
} }

View File

@ -178,7 +178,7 @@ bool InputUDPSocket::fill_current_request()
request.y_position, request.y_position,
request.z_position) ; request.z_position) ;
// Read the {MAC_AP;SS} couples (request_info) // Read the {MAC_CP;SS} couples (request_info)
unordered_map<string, Measurement> measurements ; unordered_map<string, Measurement> measurements ;
owl_request_info request_info ; owl_request_info request_info ;
for (int i = 0 ; i < request.nb_info ; ++i) for (int i = 0 ; i < request.nb_info ; ++i)
@ -193,9 +193,9 @@ bool InputUDPSocket::fill_current_request()
pkt_id_t packet_id = ntohs(request_info.packet_id) ; pkt_id_t packet_id = ntohs(request_info.packet_id) ;
string mac_ap( string mac_cp(
owl_mac_bytes_to_string(request_info.cp_mac_addr_bytes)) ; owl_mac_bytes_to_string(request_info.cp_mac_addr_bytes)) ;
PosUtil::to_upper(mac_ap) ; PosUtil::to_upper(mac_cp) ;
owl_ntoh_timestamp(&request_info.capture_time) ; owl_ntoh_timestamp(&request_info.capture_time) ;
Timestamp capture_time(request_info.capture_time) ; Timestamp capture_time(request_info.capture_time) ;
@ -206,24 +206,24 @@ bool InputUDPSocket::fill_current_request()
cerr cerr
<< "\t* Packet received from the aggregator:" << "\t* Packet received from the aggregator:"
<< "\n\t\tPacket number: " << packet_id << "\n\t\tPacket number: " << packet_id
<< "\n\t\tAP MAC: " << mac_ap << "\n\t\tCP MAC: " << mac_cp
<< "\n\t\tCapture timestamp: " << capture_time << "\n\t\tCapture timestamp: " << capture_time
<< "\n\t\tSignal: " << "\n\t\tSignal: "
<< ss << " dBm" << ss << " dBm"
<< '\n' ; << '\n' ;
if (! Configuration::bool_value("positioning.accept-new-aps") && if (! Configuration::bool_value("positioning.accept-new-cps") &&
! Stock::ap_exists(mac_ap)) ! Stock::cp_exists(mac_cp))
{ {
if (Configuration::is_configured("verbose")) if (Configuration::is_configured("verbose"))
cerr << "Dropping packet from unknown AP " cerr << "Dropping packet from unknown CP "
<< mac_ap << ".\n" ; << mac_cp << ".\n" ;
continue ; continue ;
} }
const AccessPoint &ap = Stock::find_create_ap(mac_ap) ; const CapturePoint &cp = Stock::find_create_cp(mac_cp) ;
measurements[mac_ap].set_ap(&ap) ; measurements[mac_cp].set_cp(&cp) ;
measurements[mac_ap].add_ss(packet_id, ss) ; measurements[mac_cp].add_ss(packet_id, ss) ;
} }
if (measurements.empty()) if (measurements.empty())
return false ; return false ;

View File

@ -27,7 +27,7 @@ using namespace std ;
/** /**
* Note that values pointed by #ap are not deleted. * Note that values pointed by #cp are not deleted.
*/ */
Measurement::~Measurement() Measurement::~Measurement()
{ {
@ -99,21 +99,21 @@ add_ss_list(const map<pkt_id_t, ss_t> &_ss_list)
/** /**
* Merge consists of adding the SS values of `source` to #ss_list. It * Merge consists of adding the SS values of `source` to #ss_list. It
* is possible only if the #ap of the two Measurement are identical. * is possible only if the #cp of the two Measurement are identical.
* @throw cannot_merge if the AP of the two Measurement are different. * @throw cannot_merge if the CP of the two Measurement are different.
*/ */
void Measurement::merge(const Measurement &source) void Measurement::merge(const Measurement &source)
{ {
if (ap != source.ap) if (cp != source.cp)
throw cannot_merge( throw cannot_merge(
"error when trying to merge measurements, APs are different") ; "error when trying to merge measurements, CPs are different") ;
add_ss_list(source.ss_list) ; add_ss_list(source.ss_list) ;
} }
/** /**
* - #ap is not deleted, only initialised to NULL. * - #cp is not deleted, only initialised to NULL.
* - #ss_list is cleared. * - #ss_list is cleared.
* - average and variance variables are reset to 0. * - average and variance variables are reset to 0.
*/ */
@ -127,7 +127,7 @@ void Measurement::clear()
variance_mw_m2 = 0 ; variance_mw_m2 = 0 ;
variance_dbm_m2 = 0 ; variance_dbm_m2 = 0 ;
variance_size = 0 ; variance_size = 0 ;
ap = NULL ; cp = NULL ;
} }
@ -254,7 +254,7 @@ Measurement& Measurement::operator=(const Measurement &m)
if (this == &m) if (this == &m)
return *this ; return *this ;
ap = m.ap ; cp = m.cp ;
ss_list = m.ss_list ; ss_list = m.ss_list ;
average_dbm = m.average_dbm ; average_dbm = m.average_dbm ;
average_mw = m.average_mw ; average_mw = m.average_mw ;
@ -274,7 +274,7 @@ bool Measurement::operator==(const Measurement &m) const
return true ; return true ;
return return
ap == m.ap && cp == m.cp &&
ss_list == m.ss_list ; ss_list == m.ss_list ;
} }
@ -287,9 +287,9 @@ const string Measurement::to_csv() const
if (ss_list.empty()) if (ss_list.empty())
return "" ; return "" ;
string mac_ap("") ; string mac_cp("") ;
if (ap) if (cp)
mac_ap = ap->get_mac_addr() ; mac_cp = cp->get_mac_addr() ;
for (map<pkt_id_t, ss_t>::const_iterator for (map<pkt_id_t, ss_t>::const_iterator
i = ss_list.begin() ; i != ss_list.end() ; ++i) i = ss_list.begin() ; i != ss_list.end() ; ++i)
@ -297,7 +297,7 @@ const string Measurement::to_csv() const
if (i != ss_list.begin()) if (i != ss_list.begin())
csv_line << ';' ; csv_line << ';' ;
csv_line csv_line
<< mac_ap << ';' << mac_cp << ';'
<< i->first << ';' << i->first << ';'
<< static_cast<int_fast16_t>(i->second) ; << static_cast<int_fast16_t>(i->second) ;
} }
@ -311,7 +311,7 @@ ostream &operator<<(ostream &os, const Measurement &m)
{ {
// MAC address // MAC address
os os
<< "AP: " << (m.ap ? m.ap->get_mac_addr() : "Unknown_AP") << "CP: " << (m.cp ? m.cp->get_mac_addr() : "Unknown_CP")
<< ": " ; << ": " ;
// List of SS // List of SS

View File

@ -15,7 +15,7 @@
#ifndef _OWLPS_POSITIONING_MEASUREMENT_HH_ #ifndef _OWLPS_POSITIONING_MEASUREMENT_HH_
#define _OWLPS_POSITIONING_MEASUREMENT_HH_ #define _OWLPS_POSITIONING_MEASUREMENT_HH_
#include "accesspoint.hh" #include "capturepoint.hh"
#include <map> #include <map>
#include <ostream> #include <ostream>
@ -24,12 +24,12 @@
typedef uint_fast16_t pkt_id_t ; typedef uint_fast16_t pkt_id_t ;
typedef int_fast16_t ss_t ; typedef int_fast16_t ss_t ;
/// Represents a list of signal strengths captured by one AccessPoint /// Represents a list of signal strengths captured by one CapturePoint
class Measurement class Measurement
{ {
protected: protected:
/// The AccessPoint that performed the measurement /// The CapturePoint that performed the measurement
AccessPoint *ap ; CapturePoint *cp ;
/// List of signal strengths captured (in dBm) /// List of signal strengths captured (in dBm)
std::map<pkt_id_t, ss_t> ss_list ; std::map<pkt_id_t, ss_t> ss_list ;
/// Average of all the captured signal strengths (dBm) /// Average of all the captured signal strengths (dBm)
@ -65,13 +65,13 @@ protected:
public: public:
Measurement(const AccessPoint *_ap = NULL): Measurement(const CapturePoint *_cp = NULL):
ap(const_cast<AccessPoint*>(_ap)), average_dbm(0), cp(const_cast<CapturePoint*>(_cp)), average_dbm(0),
average_mw(0), variance_mw(0), variance_dbm(0), average_mw(0), variance_mw(0), variance_dbm(0),
variance_mw_m2(0), variance_dbm_m2(0), variance_size(0) {} variance_mw_m2(0), variance_dbm_m2(0), variance_size(0) {}
Measurement(const Measurement &source): Measurement(const Measurement &source):
ap(source.ap), ss_list(source.ss_list), cp(source.cp), ss_list(source.ss_list),
average_dbm(source.average_dbm), average_mw(source.average_mw), average_dbm(source.average_dbm), average_mw(source.average_mw),
variance_mw(source.variance_mw), variance_dbm(source.variance_dbm), variance_mw(source.variance_mw), variance_dbm(source.variance_dbm),
variance_mw_m2(0), variance_dbm_m2(0), variance_size(0) {} variance_mw_m2(0), variance_dbm_m2(0), variance_size(0) {}
@ -80,8 +80,8 @@ public:
/** @name Read accessors */ /** @name Read accessors */
//@{ //@{
/// Returns the AccessPoint associated with the Measurement /// Returns the CapturePoint associated with the Measurement
AccessPoint* get_ap() const ; CapturePoint* get_cp() const ;
/// Returns the packet number `pkt_id` /// Returns the packet number `pkt_id`
ss_t get_ss(pkt_id_t pkt_id) const ; ss_t get_ss(pkt_id_t pkt_id) const ;
/// Returns the mean of the SS list, in dBm /// Returns the mean of the SS list, in dBm
@ -98,8 +98,8 @@ public:
/** @name Write accessors */ /** @name Write accessors */
//@{ //@{
/// Associate the Measurement with an AccessPoint /// Associate the Measurement with a CapturePoint
void set_ap(const AccessPoint *_ap) ; void set_cp(const CapturePoint *_cp) ;
/// Adds a signal strength (in dBm) to #ss_list /// Adds a signal strength (in dBm) to #ss_list
void add_ss(const pkt_id_t packet_id, const ss_t ss_dbm) ; void add_ss(const pkt_id_t packet_id, const ss_t ss_dbm) ;
/// Adds several signal strengths (in dBm) to #ss_list /// Adds several signal strengths (in dBm) to #ss_list
@ -147,9 +147,9 @@ public:
/* *** Read accessors *** */ /* *** Read accessors *** */
inline AccessPoint* Measurement::get_ap() const inline CapturePoint* Measurement::get_cp() const
{ {
return ap ; return cp ;
} }
@ -187,9 +187,9 @@ inline int Measurement::get_nb_ss() const
/* *** Write accessors *** */ /* *** Write accessors *** */
inline void Measurement::set_ap(const AccessPoint *_ap) inline void Measurement::set_cp(const CapturePoint *_cp)
{ {
ap = const_cast<AccessPoint*>(_ap) ; cp = const_cast<CapturePoint*>(_cp) ;
} }
@ -241,7 +241,7 @@ inline bool Measurement::operator!=(const Measurement &m) const
inline Measurement::operator bool() const inline Measurement::operator bool() const
{ {
return return
ap != NULL || cp != NULL ||
! ss_list.empty() ; ! ss_list.empty() ;
} }

View File

@ -13,18 +13,18 @@
#include "minmax.hh" #include "minmax.hh"
#include "accesspoint.hh" #include "capturepoint.hh"
using namespace std ; using namespace std ;
Point3D MinMax::trilaterate( Point3D MinMax::trilaterate(
const unordered_map<AccessPoint*, float> &_ap_distances) const unordered_map<CapturePoint*, float> &_cp_distances)
{ {
min = INFINITE ; min = INFINITE ;
centre = start ; centre = start ;
ap_distances = &_ap_distances ; cp_distances = &_cp_distances ;
for (float x = start.get_x() ; x <= stop.get_x() ; x += step) for (float x = start.get_x() ; x <= stop.get_x() ; x += step)
for (float y = start.get_y() ; y <= stop.get_y() ; y += step) for (float y = start.get_y() ; y <= stop.get_y() ; y += step)
@ -36,11 +36,11 @@ Point3D MinMax::trilaterate(
Point3D MinMax::trilaterate_2d( Point3D MinMax::trilaterate_2d(
const unordered_map<AccessPoint*, float> &_ap_distances, float z) const unordered_map<CapturePoint*, float> &_cp_distances, float z)
{ {
min = INFINITE ; min = INFINITE ;
centre = start ; centre = start ;
ap_distances = &_ap_distances ; cp_distances = &_cp_distances ;
for (float x = start.get_x() ; x <= stop.get_x() ; x += step) for (float x = start.get_x() ; x <= stop.get_x() ; x += step)
for (float y = start.get_y() ; y <= stop.get_y() ; y += step) for (float y = start.get_y() ; y <= stop.get_y() ; y += step)
@ -53,8 +53,8 @@ Point3D MinMax::trilaterate_2d(
void MinMax::iterate(float x, float y, float z) void MinMax::iterate(float x, float y, float z)
{ {
float d_max = 0 ; float d_max = 0 ;
for (unordered_map<AccessPoint*, float>::const_iterator i = for (unordered_map<CapturePoint*, float>::const_iterator i =
ap_distances->begin() ; i != ap_distances->end() ; ++i) cp_distances->begin() ; i != cp_distances->end() ; ++i)
{ {
float dist = float dist =
Point3D(x, y, z).distance_to_sphere( Point3D(x, y, z).distance_to_sphere(

View File

@ -23,7 +23,7 @@ class MinMax: public TrilaterationMethod
private: private:
float min ; float min ;
Point3D centre ; Point3D centre ;
std::unordered_map<AccessPoint*, float> const *ap_distances ; std::unordered_map<CapturePoint*, float> const *cp_distances ;
void iterate(float x, float y, float z) ; void iterate(float x, float y, float z) ;
@ -45,9 +45,9 @@ public:
~MinMax(void) {} ~MinMax(void) {}
Point3D trilaterate( Point3D trilaterate(
const std::unordered_map<AccessPoint*, float> &_ap_distances) ; const std::unordered_map<CapturePoint*, float> &_cp_distances) ;
Point3D trilaterate_2d( Point3D trilaterate_2d(
const std::unordered_map<AccessPoint*, float> &_ap_distances, const std::unordered_map<CapturePoint*, float> &_cp_distances,
float z) ; float z) ;
} ; } ;

View File

@ -23,7 +23,7 @@ class Point3D ;
/// Reads and registers to the Stock Mobile list from CSV files /// Reads and registers to the Stock Mobile list from CSV files
/** /**
* CSV format for access points is: * CSV format for capture points is:
* MAC;Antenna_gain_dBi;Trx_power_dBm * MAC;Antenna_gain_dBi;Trx_power_dBm
*/ */
class MobilesReaderCSV class MobilesReaderCSV

View File

@ -46,11 +46,11 @@ double PosUtil::rad2deg(const double &radians)
/** /**
* APs that have not captured a Request must not have too much weight in * CPs that have not captured a Request must not have too much weight in
* the computation. Thus, in the measurements lists we compare, we add * the computation. Thus, in the measurements lists we compare, we add
* missing APs with a very low SS value. * missing CPs with a very low SS value.
* *
* Both lists can be completed, depending of the APs they contain. * Both lists can be completed, depending of the CPs they contain.
* Both lists must initially contain at least one measurement. * Both lists must initially contain at least one measurement.
*/ */
void PosUtil::complete_with_dummy_measurements( void PosUtil::complete_with_dummy_measurements(
@ -67,7 +67,7 @@ void PosUtil::complete_with_dummy_measurements(
measurements1.begin() ; i != measurements1.end() ; ++i) measurements1.begin() ; i != measurements1.end() ; ++i)
if (measurements2.find(i->first) == measurements2.end()) if (measurements2.find(i->first) == measurements2.end())
{ {
dummy.set_ap(&Stock::get_ap(i->first)) ; dummy.set_cp(&Stock::get_cp(i->first)) ;
measurements2[i->first] = dummy ; measurements2[i->first] = dummy ;
} }
@ -75,7 +75,7 @@ void PosUtil::complete_with_dummy_measurements(
measurements2.begin() ; i != measurements2.end() ; ++i) measurements2.begin() ; i != measurements2.end() ; ++i)
if (measurements1.find(i->first) == measurements1.end()) if (measurements1.find(i->first) == measurements1.end())
{ {
dummy.set_ap(&Stock::get_ap(i->first)) ; dummy.set_cp(&Stock::get_cp(i->first)) ;
measurements1[i->first] = dummy ; measurements1[i->first] = dummy ;
} }
} }

View File

@ -46,7 +46,7 @@ public:
/** @name Measurements */ /** @name Measurements */
//@{ //@{
/// Mutually completes two Measurement lists with missing APs /// Mutually completes two Measurement lists with missing CPs
static void complete_with_dummy_measurements( static void complete_with_dummy_measurements(
std::unordered_map<std::string, Measurement> &measurements1, std::unordered_map<std::string, Measurement> &measurements1,
std::unordered_map<std::string, Measurement> &measurements2) ; std::unordered_map<std::string, Measurement> &measurements2) ;

View File

@ -171,25 +171,25 @@ bool ReferencePoint::delete_generated_requests(void)
while (r != requests.end()) while (r != requests.end())
{ {
assert(*r) ; assert(*r) ;
unordered_map<std::string, AccessPoint>::const_iterator ap ; unordered_map<std::string, CapturePoint>::const_iterator cp ;
if ((*r)->get_mobile() == NULL) if ((*r)->get_mobile() == NULL)
goto delete_request ; goto delete_request ;
// Check if the request was sent by an AP // Check if the request was sent by a CP
for (ap = Stock::get_aps().begin() ; ap != Stock::get_aps().end() ; for (cp = Stock::get_cps().begin() ; cp != Stock::get_cps().end() ;
++ap) ++cp)
if ((*r)->get_mobile()->get_mac_addr() == if ((*r)->get_mobile()->get_mac_addr() ==
ap->second.get_mac_addr()) cp->second.get_mac_addr())
break ; break ;
if (ap != Stock::get_aps().end()) // r was sent by an AP if (cp != Stock::get_cps().end()) // r was sent by a CP
{ {
++r ; ++r ;
continue ; // Do not delete r continue ; // Do not delete r
} }
// r is not associated with an AP, delete it // r is not associated with a CP, delete it
delete_request: delete_request:
Stock::delete_calibration_request(**r) ; Stock::delete_calibration_request(**r) ;
r = requests.erase(r) ; r = requests.erase(r) ;
@ -228,20 +228,20 @@ float ReferencePoint::similarity(const Request &source) const
/** /**
* @param ap_mac The MAC address of the AccessPoint to work on. * @param cp_mac The MAC address of the CapturePoint to work on.
* *
* @returns The Friis index associated to the AccessPoint. * @returns The Friis index associated to the CapturePoint.
* @returns 0 if the AP is unknown at this ReferencePoint. * @returns 0 if the CP is unknown at this ReferencePoint.
*/ */
float ReferencePoint:: float ReferencePoint::
friis_index_for_ap(const string &ap_mac) const friis_index_for_cp(const string &cp_mac) const
{ {
const AccessPoint &ap = Stock::get_ap(ap_mac) ; const CapturePoint &cp = Stock::get_cp(cp_mac) ;
double const_term = ap.friis_constant_term() ; double const_term = cp.friis_constant_term() ;
int nb_friis_idx = 0 ; int nb_friis_idx = 0 ;
double friis_idx_sum = double friis_idx_sum =
friis_indexes_for_ap(ap, const_term, nb_friis_idx) ; friis_indexes_for_cp(cp, const_term, nb_friis_idx) ;
if (nb_friis_idx == 0) if (nb_friis_idx == 0)
return 0 ; return 0 ;
@ -250,32 +250,32 @@ friis_index_for_ap(const string &ap_mac) const
/** /**
* Computes a Friis index sum for the distance AP-ReferencePoint, * Computes a Friis index sum for the distance CP-ReferencePoint,
* based on the measurements of this AP that are present in the * based on the measurements of this CP that are present in the
* ReferencePoint. To obtain the real (averaged) Friis index, one * ReferencePoint. To obtain the real (averaged) Friis index, one
* has to divide the returned sum by the number of indexes. * has to divide the returned sum by the number of indexes.
* *
* @param ap The AccessPoint to work on. * @param cp The CapturePoint to work on.
* @param const_term The "constant" part of the computation. * @param const_term The "constant" part of the computation.
* @param nb_indexes (result) The number of indexes computed. * @param nb_indexes (result) The number of indexes computed.
* *
* @returns The sum of all Friis indexes for the AccessPoint. * @returns The sum of all Friis indexes for the CapturePoint.
* @returns 0 if the AP is unknown at this ReferencePoint. * @returns 0 if the CP is unknown at this ReferencePoint.
*/ */
float ReferencePoint::friis_indexes_for_ap( float ReferencePoint::friis_indexes_for_cp(
const AccessPoint &ap, const CapturePoint &cp,
const double &const_term, const double &const_term,
int &nb_indexes) const int &nb_indexes) const
{ {
nb_indexes = 0 ; nb_indexes = 0 ;
double friis_idx_sum = 0 ; double friis_idx_sum = 0 ;
const string &ap_mac = ap.get_mac_addr() ; const string &cp_mac = cp.get_mac_addr() ;
float distance = this->distance(ap.get_coordinates()) ; float distance = this->distance(cp.get_coordinates()) ;
/* /*
* Compute an index for the AP's Measurement in each Request in the * Compute an index for the CP's Measurement in each Request in the
* ReferencePoint. The Friis index for the AP is the average of all * ReferencePoint. The Friis index for the CP is the average of all
* these indexes (we do not compute the average in this function). * these indexes (we do not compute the average in this function).
*/ */
for (vector<CalibrationRequest*>::const_iterator request = for (vector<CalibrationRequest*>::const_iterator request =
@ -284,7 +284,7 @@ float ReferencePoint::friis_indexes_for_ap(
const unordered_map<string, Measurement> &measurements = const unordered_map<string, Measurement> &measurements =
(*request)->get_measurements() ; (*request)->get_measurements() ;
unordered_map<string, Measurement>::const_iterator measurement = unordered_map<string, Measurement>::const_iterator measurement =
measurements.find(ap_mac) ; measurements.find(cp_mac) ;
if (measurement != measurements.end()) if (measurement != measurements.end())
{ {
float ss = measurement->second.get_average_dbm() ; float ss = measurement->second.get_average_dbm() ;
@ -305,25 +305,25 @@ float ReferencePoint::friis_indexes_for_ap(
/** /**
* Computes a Friis index for the distance AP-ReferencePoint, based on a * Computes a Friis index for the distance CP-ReferencePoint, based on a
* given packet (`pkt_id),` of a measurement of this AP present in the * given packet (`pkt_id),` of a measurement of this CP present in the
* ReferencePoint. This measurement is the first found in the * ReferencePoint. This measurement is the first found in the
* ReferencePoint. This works well when we keep only one calibration * ReferencePoint. This works well when we keep only one calibration
* request per reference point. * request per reference point.
* *
* @param ap_mac The MAC address of the AccessPoint to work on. * @param cp_mac The MAC address of the CapturePoint to work on.
* @param pkt_id The packet ID to look for. * @param pkt_id The packet ID to look for.
* *
* @returns The Friis index for this AP and packet. * @returns The Friis index for this CP and packet.
* @returns 0 if the AP is unknown at this ReferencePoint, or if there * @returns 0 if the CP is unknown at this ReferencePoint, or if there
* is no packet with the wanted ID. * is no packet with the wanted ID.
*/ */
float ReferencePoint:: float ReferencePoint::
friis_index_for_ap(const string &ap_mac, pkt_id_t pkt_id) const friis_index_for_cp(const string &cp_mac, pkt_id_t pkt_id) const
{ {
const AccessPoint &ap = Stock::get_ap(ap_mac) ; const CapturePoint &cp = Stock::get_cp(cp_mac) ;
double const_term = ap.friis_constant_term() ; double const_term = cp.friis_constant_term() ;
float distance = this->distance(ap.get_coordinates()) ; float distance = this->distance(cp.get_coordinates()) ;
float friis_idx = 0 ; float friis_idx = 0 ;
for (vector<CalibrationRequest*>::const_iterator request = for (vector<CalibrationRequest*>::const_iterator request =
@ -332,7 +332,7 @@ friis_index_for_ap(const string &ap_mac, pkt_id_t pkt_id) const
const unordered_map<string, Measurement> &measurements = const unordered_map<string, Measurement> &measurements =
(*request)->get_measurements() ; (*request)->get_measurements() ;
unordered_map<string, Measurement>::const_iterator measurement = unordered_map<string, Measurement>::const_iterator measurement =
measurements.find(ap_mac) ; measurements.find(cp_mac) ;
if (measurement == measurements.end()) if (measurement == measurements.end())
continue ; continue ;
ss_t ss = measurement->second.get_ss(pkt_id) ; ss_t ss = measurement->second.get_ss(pkt_id) ;

View File

@ -15,7 +15,7 @@
#ifndef _OWLPS_POSITIONING_REFERENCEPOINT_HH_ #ifndef _OWLPS_POSITIONING_REFERENCEPOINT_HH_
#define _OWLPS_POSITIONING_REFERENCEPOINT_HH_ #define _OWLPS_POSITIONING_REFERENCEPOINT_HH_
class AccessPoint ; class CapturePoint ;
class CalibrationRequest ; class CalibrationRequest ;
class Request ; class Request ;
@ -75,7 +75,7 @@ public:
void delete_request(const CalibrationRequest *r) ; void delete_request(const CalibrationRequest *r) ;
/// Deletes all the requests contained in #requests /// Deletes all the requests contained in #requests
void delete_requests(void) ; void delete_requests(void) ;
/// Deletes the requests that are not sent by an AP /// Deletes the requests that are not sent by a CP
bool delete_generated_requests(void) ; bool delete_generated_requests(void) ;
//@} //@}
@ -83,15 +83,15 @@ public:
//@{ //@{
/// Computes the similarity of the ReferencePoint and a Request /// Computes the similarity of the ReferencePoint and a Request
float similarity(const Request &source) const ; float similarity(const Request &source) const ;
/// Computes the Friis index for the given AccessPoint /// Computes the Friis index for the given CapturePoint
float friis_index_for_ap(const std::string &ap_mac) const ; float friis_index_for_cp(const std::string &cp_mac) const ;
/// Computes the Friis indexes sum for the given AccessPoint /// Computes the Friis indexes sum for the given CapturePoint
float friis_indexes_for_ap( float friis_indexes_for_cp(
const AccessPoint &ap, const double &const_term, const CapturePoint &cp, const double &const_term,
int &nb_indexes) const ; int &nb_indexes) const ;
/// Computes the Friis index for the given AccessPoint and packet ID /// Computes the Friis index for the given CapturePoint and packet ID
float friis_index_for_ap( float friis_index_for_cp(
const std::string &ap_mac, pkt_id_t pkt_id) const ; const std::string &cp_mac, pkt_id_t pkt_id) const ;
//@} //@}
/** @name Operators */ /** @name Operators */

View File

@ -84,9 +84,9 @@ Request::~Request()
/** /**
* @param mac_receiver The MAC address of the receiver AP. * @param mac_receiver The MAC address of the receiver CP.
* @returns A pointer on the found measurement, or NULL if no * @returns A pointer on the found measurement, or NULL if no
* measurement was made by this AP. * measurement was made by this CP.
*/ */
const Measurement* const Measurement*
Request::get_measurement(const string &mac_receiver) const Request::get_measurement(const string &mac_receiver) const

View File

@ -43,7 +43,7 @@ protected:
Timestamp time_received ; Timestamp time_received ;
/// List of Measurement of the request /// List of Measurement of the request
/** Note that this is not a pointer list, values are actually stored. /** Note that this is not a pointer list, values are actually stored.
The `string` parameter is the MAC address of the receiver AP. */ The `string` parameter is the MAC address of the receiver CP. */
std::unordered_map<std::string, Measurement> measurements ; std::unordered_map<std::string, Measurement> measurements ;
/// Real coordinates of the request (normally unavailable for a /// Real coordinates of the request (normally unavailable for a
/// standard positioning request) /// standard positioning request)
@ -92,7 +92,7 @@ public:
/// Returns all the measurements /// Returns all the measurements
const std::unordered_map<std::string, Measurement>& const std::unordered_map<std::string, Measurement>&
get_measurements(void) const ; get_measurements(void) const ;
/// Returns the measurement made by the AP `mac_receiver,` if any /// Returns the measurement made by the CP `mac_receiver,` if any
const Measurement* const Measurement*
get_measurement(const std::string &mac_receiver) const ; get_measurement(const std::string &mac_receiver) const ;
const Point3D* get_real_position(void) const ; const Point3D* get_real_position(void) const ;

View File

@ -32,7 +32,7 @@ unordered_map<Point3D, Waypoint> Stock::waypoints ;
unordered_map<string, Mobile> Stock::mobiles ; unordered_map<string, Mobile> Stock::mobiles ;
unordered_map<string, AccessPoint> Stock::aps ; unordered_map<string, CapturePoint> Stock::cps ;
unordered_set<ReferencePoint> Stock::reference_points ; unordered_set<ReferencePoint> Stock::reference_points ;
@ -49,7 +49,7 @@ void Stock::clear()
waypoints.clear() ; waypoints.clear() ;
mobiles.clear() ; mobiles.clear() ;
aps.clear() ; cps.clear() ;
reference_points.clear() ; reference_points.clear() ;
calibration_requests.clear() ; calibration_requests.clear() ;
} }
@ -211,114 +211,114 @@ const Mobile& Stock::find_create_mobile(const Mobile &source)
/* *** AccessPoint operations *** */ /* *** CapturePoint operations *** */
/** /**
* @param mac The MAC address of the AccessPoint to search for. * @param mac The MAC address of the CapturePoint to search for.
* It must be a valid MAC address, as no check is performed. * It must be a valid MAC address, as no check is performed.
* @returns `true` if an AP with this MAC address exists. * @returns `true` if a CP with this MAC address exists.
* @returns `false` if this MAC address was not found. * @returns `false` if this MAC address was not found.
*/ */
bool Stock::ap_exists(const std::string &mac) bool Stock::cp_exists(const std::string &mac)
{ {
unordered_map<string, AccessPoint>::const_iterator i = aps.find(mac) ; unordered_map<string, CapturePoint>::const_iterator i = cps.find(mac) ;
return i != aps.end() ; return i != cps.end() ;
} }
/** /**
* @param mac The MAC address of the AccessPoint to search for. * @param mac The MAC address of the CapturePoint to search for.
* It must be a valid MAC address, as no check is performed. * It must be a valid MAC address, as no check is performed.
* @returns A const reference to the AccessPoint. * @returns A const reference to the CapturePoint.
* @throw element_not_found is thrown if the AccessPoint corresponding * @throw element_not_found is thrown if the CapturePoint corresponding
* to `mac` does not exist. * to `mac` does not exist.
*/ */
const AccessPoint& Stock::get_ap(const string &mac) const CapturePoint& Stock::get_cp(const string &mac)
{ {
unordered_map<string, AccessPoint>::const_iterator i = aps.find(mac) ; unordered_map<string, CapturePoint>::const_iterator i = cps.find(mac) ;
if (i != aps.end()) if (i != cps.end())
return i->second ; return i->second ;
throw element_not_found("No AccessPoint with MAC address \"" + throw element_not_found("No CapturePoint with MAC address \"" +
mac + "\"!") ; mac + "\"!") ;
} }
/** /**
* The MAC address of the AccessPoint is initialised. * The MAC address of the CapturePoint is initialised.
*/ */
const AccessPoint& Stock::find_create_ap(const string &mac) const CapturePoint& Stock::find_create_cp(const string &mac)
{ {
unordered_map<string, AccessPoint>::const_iterator i = aps.find(mac) ; unordered_map<string, CapturePoint>::const_iterator i = cps.find(mac) ;
if (i != aps.end()) if (i != cps.end())
return i->second ; return i->second ;
AccessPoint &ap = aps[mac] ; CapturePoint &cp = cps[mac] ;
ap.set_mac_addr(mac) ; cp.set_mac_addr(mac) ;
if (Configuration::is_configured("verbose")) if (Configuration::is_configured("verbose"))
cerr cerr
<< "New AP \"" << mac << "New CP \"" << mac
<< "\" (total: " << nb_aps() << " APs).\n" ; << "\" (total: " << nb_cps() << " CPs).\n" ;
return ap ; return cp ;
} }
/** /**
* If the AccessPoint already exists, it is replaced by `source.` * If the CapturePoint already exists, it is replaced by `source.`
*/ */
const AccessPoint& Stock::find_create_ap(const AccessPoint &source) const CapturePoint& Stock::find_create_cp(const CapturePoint &source)
{ {
const string &mac = source.get_mac_addr() ; const string &mac = source.get_mac_addr() ;
unordered_map<string, AccessPoint>::const_iterator i = aps.find(mac) ; unordered_map<string, CapturePoint>::const_iterator i = cps.find(mac) ;
if (i != aps.end()) if (i != cps.end())
return i->second ; return i->second ;
aps[mac] = source ; cps[mac] = source ;
return aps[mac] ; return cps[mac] ;
} }
void Stock::update_all_friis_indexes() void Stock::update_all_friis_indexes()
{ {
for (unordered_map<string, AccessPoint>::iterator ap = aps.begin() ; for (unordered_map<string, CapturePoint>::iterator cp = cps.begin() ;
ap != aps.end() ; ++ap) cp != cps.end() ; ++cp)
{ {
double friis_idx_sum = 0 ; double friis_idx_sum = 0 ;
int nb_friis_idx = 0 ; int nb_friis_idx = 0 ;
// Compute main general term, independant from scans // Compute main general term, independant from scans
double const_term = ap->second.friis_constant_term() ; double const_term = cp->second.friis_constant_term() ;
/* /*
* Compute indexes for each ReferencePoint. The Friis index for an * Compute indexes for each ReferencePoint. The Friis index for an
* AP is the average of all indexes in all ReferencePoint. * CP is the average of all indexes in all ReferencePoint.
*/ */
for (unordered_set<ReferencePoint>::const_iterator rp = for (unordered_set<ReferencePoint>::const_iterator rp =
reference_points.begin() ; rp != reference_points.end() ; reference_points.begin() ; rp != reference_points.end() ;
++rp) ++rp)
{ {
int nb_idx = 0 ; int nb_idx = 0 ;
float ap_friis_idx_sum = float cp_friis_idx_sum =
rp->friis_indexes_for_ap(ap->second, const_term, nb_idx) ; rp->friis_indexes_for_cp(cp->second, const_term, nb_idx) ;
if (nb_idx != 0) if (nb_idx != 0)
{ {
friis_idx_sum += ap_friis_idx_sum ; friis_idx_sum += cp_friis_idx_sum ;
nb_friis_idx += nb_idx ; nb_friis_idx += nb_idx ;
} }
} }
if (nb_friis_idx > 0) if (nb_friis_idx > 0)
ap->second.set_friis_index(friis_idx_sum / nb_friis_idx) ; cp->second.set_friis_index(friis_idx_sum / nb_friis_idx) ;
} }
} }
double Stock::ap_matrix_get_ss(const std::string &mac_transmitter, double Stock::cp_matrix_get_ss(const std::string &mac_transmitter,
const std::string &mac_receiver) const std::string &mac_receiver)
{ {
const AccessPoint &receiver = get_ap(mac_receiver) ; const CapturePoint &receiver = get_cp(mac_receiver) ;
const ReferencePoint &rp = const ReferencePoint &rp =
get_reference_point(receiver.get_coordinates()) ; get_reference_point(receiver.get_coordinates()) ;
@ -328,13 +328,13 @@ double Stock::ap_matrix_get_ss(const std::string &mac_transmitter,
/** /**
* @returns `true` if `coord` are the coordinates of an existing * @returns `true` if `coord` are the coordinates of an existing
* AP, `false` if not. * CP, `false` if not.
*/ */
bool Stock::is_ap_coordinate(const Point3D &coord) bool Stock::is_cp_coordinate(const Point3D &coord)
{ {
for (unordered_map<string, AccessPoint>::const_iterator ap = for (unordered_map<string, CapturePoint>::const_iterator cp =
aps.begin() ; ap != aps.end() ; ++ap) cps.begin() ; cp != cps.end() ; ++cp)
if (ap->second.get_coordinates() == coord) if (cp->second.get_coordinates() == coord)
return true ; return true ;
return false ; return false ;
@ -390,21 +390,21 @@ closest_reference_point(const Request &request)
"Cannot search for the closest reference point: reference points'" "Cannot search for the closest reference point: reference points'"
" list is empty!") ; " list is empty!") ;
bool ignore_aps = Configuration::bool_value( bool ignore_cps = Configuration::bool_value(
"positioning.nss.ignore-ap-reference-points") ; "positioning.nss.ignore-cp-reference-points") ;
unordered_set<ReferencePoint>::const_iterator i = unordered_set<ReferencePoint>::const_iterator i =
reference_points.begin() ; reference_points.begin() ;
if (ignore_aps) if (ignore_cps)
{ {
// Fast-forward to the next non-AP reference point // Fast-forward to the next non-CP reference point
while (i != reference_points.end() && is_ap_coordinate(*i)) while (i != reference_points.end() && is_cp_coordinate(*i))
++i ; ++i ;
// No non-AP reference point was found, we are forced to consider // No non-CP reference point was found, we are forced to consider
// the AP reference points // the CP reference points
if (i == reference_points.end()) if (i == reference_points.end())
ignore_aps = false ; ignore_cps = false ;
} }
float similarity = i->similarity(request) ; float similarity = i->similarity(request) ;
@ -412,7 +412,7 @@ closest_reference_point(const Request &request)
for (++i ; i != reference_points.end() ; ++i) for (++i ; i != reference_points.end() ; ++i)
{ {
if (ignore_aps && is_ap_coordinate(*i)) if (ignore_cps && is_cp_coordinate(*i))
continue ; continue ;
float tmp_similarity = i->similarity(request) ; float tmp_similarity = i->similarity(request) ;
@ -430,10 +430,10 @@ closest_reference_point(const Request &request)
void Stock::regenerate_reference_points() void Stock::regenerate_reference_points()
{ {
assert(Configuration::autocalibration_enabled()) ; assert(Configuration::autocalibration_enabled()) ;
assert(! aps.empty()) ; assert(! cps.empty()) ;
assert(! reference_points.empty()) ; assert(! reference_points.empty()) ;
delete_non_ap_calibration_requests() ; delete_non_cp_calibration_requests() ;
if (reference_points.size() < 3) if (reference_points.size() < 3)
{ {
@ -604,24 +604,24 @@ closest_calibration_request(const Request &request)
"Cannot search for the closest calibration request: calibration" "Cannot search for the closest calibration request: calibration"
" requests' list is empty!") ; " requests' list is empty!") ;
bool ignore_aps = Configuration::bool_value( bool ignore_cps = Configuration::bool_value(
"positioning.nss.ignore-ap-reference-points") ; "positioning.nss.ignore-cp-reference-points") ;
unordered_set<CalibrationRequest>::const_iterator i = unordered_set<CalibrationRequest>::const_iterator i =
calibration_requests.begin() ; calibration_requests.begin() ;
if (ignore_aps) if (ignore_cps)
{ {
// Fast-forward to the next non-AP reference point // Fast-forward to the next non-CP reference point
while (i != calibration_requests.end() && while (i != calibration_requests.end() &&
is_ap_coordinate(*i->get_reference_point())) is_cp_coordinate(*i->get_reference_point()))
++i ; ++i ;
// No non-AP reference point was found, we are forced to consider // No non-CP reference point was found, we are forced to consider
// the AP reference points // the CP reference points
if (i == calibration_requests.end()) if (i == calibration_requests.end())
{ {
i = calibration_requests.begin() ; i = calibration_requests.begin() ;
ignore_aps = false ; ignore_cps = false ;
} }
} }
@ -630,7 +630,7 @@ closest_calibration_request(const Request &request)
for (++i ; i != calibration_requests.end() ; ++i) for (++i ; i != calibration_requests.end() ; ++i)
{ {
if (ignore_aps && is_ap_coordinate(*i->get_reference_point())) if (ignore_cps && is_cp_coordinate(*i->get_reference_point()))
continue ; continue ;
assert(! i->get_measurements().empty()) ; assert(! i->get_measurements().empty()) ;
@ -647,7 +647,7 @@ closest_calibration_request(const Request &request)
} }
void Stock::delete_non_ap_calibration_requests() void Stock::delete_non_cp_calibration_requests()
{ {
unordered_set<ReferencePoint>::iterator rp = reference_points.begin() ; unordered_set<ReferencePoint>::iterator rp = reference_points.begin() ;
while (rp != reference_points.end()) while (rp != reference_points.end())

View File

@ -19,7 +19,7 @@
#include "building.hh" #include "building.hh"
#include "waypoint.hh" #include "waypoint.hh"
#include "mobile.hh" #include "mobile.hh"
#include "accesspoint.hh" #include "capturepoint.hh"
#include "referencepoint.hh" #include "referencepoint.hh"
#include "calibrationrequest.hh" #include "calibrationrequest.hh"
@ -43,9 +43,9 @@ private:
/** The string key of the map is the Mobile MAC address. */ /** The string key of the map is the Mobile MAC address. */
static std::unordered_map<std::string, Mobile> mobiles ; static std::unordered_map<std::string, Mobile> mobiles ;
/// List of known AccessPoint /// List of known CapturePoint
/** The string key of the map is the AccessPoint MAC address. */ /** The string key of the map is the CapturePoint MAC address. */
static std::unordered_map<std::string, AccessPoint> aps ; static std::unordered_map<std::string, CapturePoint> cps ;
/// List of known ReferencePoint /// List of known ReferencePoint
static std::unordered_set<ReferencePoint> reference_points ; static std::unordered_set<ReferencePoint> reference_points ;
@ -55,8 +55,8 @@ private:
/** @name CalibrationRequest operations */ /** @name CalibrationRequest operations */
//@{ //@{
/// Delete calibration requests that do not come from the APs /// Delete calibration requests that do not come from the CPs
static void delete_non_ap_calibration_requests(void) ; static void delete_non_cp_calibration_requests(void) ;
//@} //@}
/** @name ReferencePoint operations */ /** @name ReferencePoint operations */
@ -118,33 +118,33 @@ public:
static Mobile& getw_mobile(const std::string &mac) ; static Mobile& getw_mobile(const std::string &mac) ;
//@} //@}
/** @name AccessPoint operations */ /** @name CapturePoint operations */
//@{ //@{
/// Returns the number of access points /// Returns the number of capture points
static unsigned int nb_aps(void) ; static unsigned int nb_cps(void) ;
/// Returns a reference to the AP list /// Returns a reference to the CP list
static static
std::unordered_map<std::string, AccessPoint>& get_aps(void) ; std::unordered_map<std::string, CapturePoint>& get_cps(void) ;
/// Verify the existence of an AP /// Verify the existence of a CP
static bool ap_exists(const std::string &mac) ; static bool cp_exists(const std::string &mac) ;
/// Reads the AccessPoint corresponding to a given MAC address /// Reads the CapturePoint corresponding to a given MAC address
static const AccessPoint& get_ap(const std::string &mac) ; static const CapturePoint& get_cp(const std::string &mac) ;
/// Searches for an AccessPoint given its MAC address and creates it /// Searches for a CapturePoint given its MAC address and creates it
/// if it does not exist /// if it does not exist
static const AccessPoint& find_create_ap(const std::string &mac) ; static const CapturePoint& find_create_cp(const std::string &mac) ;
/// Searches for an AccessPoint and create it if it does not exist /// Searches for a CapturePoint and create it if it does not exist
static const AccessPoint& find_create_ap(const AccessPoint &source) ; static const CapturePoint& find_create_cp(const CapturePoint &source) ;
/// Returns a reference to the AccessPoint corresponding to a given /// Returns a reference to the CapturePoint corresponding to a given
/// MAC address /// MAC address
static AccessPoint& getw_ap(const std::string &mac) ; static CapturePoint& getw_cp(const std::string &mac) ;
/// Updates the friis indexes of all the APs /// Updates the friis indexes of all the CPs
static void update_all_friis_indexes(void) ; static void update_all_friis_indexes(void) ;
/// Returns the signal strenth received by an AP `mac_receiver` from /// Returns the signal strenth received by a CP `mac_receiver` from
/// an AP `mac_transmitter` /// a CP `mac_transmitter`
static double ap_matrix_get_ss(const std::string &mac_transmitter, static double cp_matrix_get_ss(const std::string &mac_transmitter,
const std::string &mac_receiver) ; const std::string &mac_receiver) ;
/// Checks if a Point3D is the coordinate of an existing AP /// Checks if a Point3D is the coordinate of an existing CP
static bool is_ap_coordinate(const Point3D &coord) ; static bool is_cp_coordinate(const Point3D &coord) ;
//@} //@}
/** @name ReferencePoint operations */ /** @name ReferencePoint operations */
@ -164,7 +164,7 @@ public:
static const ReferencePoint& static const ReferencePoint&
closest_reference_point(const Request &request) ; closest_reference_point(const Request &request) ;
/// Generates reference points from the reference points corresponding /// Generates reference points from the reference points corresponding
/// to APs /// to CPs
static void regenerate_reference_points(void) ; static void regenerate_reference_points(void) ;
//@} //@}
@ -250,32 +250,32 @@ inline Mobile& Stock::getw_mobile(const std::string &mac)
/* *** AccessPoint operations *** */ /* *** CapturePoint operations *** */
inline unsigned int Stock::nb_aps() inline unsigned int Stock::nb_cps()
{ {
return aps.size() ; return cps.size() ;
} }
inline inline
std::unordered_map<std::string, AccessPoint>& Stock::get_aps() std::unordered_map<std::string, CapturePoint>& Stock::get_cps()
{ {
return aps ; return cps ;
} }
/** /**
* If the AccessPoint corresponding to `mac` does not exist, it is * If the CapturePoint corresponding to `mac` does not exist, it is
* created. * created.
* @param mac The MAC address of the AccessPoint to search for. * @param mac The MAC address of the CapturePoint to search for.
* It must be a valid MAC address, as no check is performed. * It must be a valid MAC address, as no check is performed.
* @returns A modifiable reference to the AccessPoint. * @returns A modifiable reference to the CapturePoint.
*/ */
inline AccessPoint& Stock::getw_ap(const std::string &mac) inline CapturePoint& Stock::getw_cp(const std::string &mac)
{ {
return aps[mac] ; return cps[mac] ;
} }

View File

@ -62,11 +62,11 @@ make_constant_term(const Measurement &measurement)
assert(request) ; assert(request) ;
const Mobile *mobile = request->get_mobile() ; const Mobile *mobile = request->get_mobile() ;
assert(mobile) ; assert(mobile) ;
const AccessPoint *ap = measurement.get_ap() ; const CapturePoint *cp = measurement.get_cp() ;
assert(ap) ; assert(cp) ;
return return
ap->friis_constant_term() + cp->friis_constant_term() +
mobile->get_antenna_gain() + mobile->get_antenna_gain() +
mobile->get_trx_power() ; mobile->get_trx_power() ;
} }
@ -76,21 +76,21 @@ Result TrilaterationAlgorithm::compute(const Request &_request)
{ {
request = &_request ; request = &_request ;
compute_ap_distance_circles() ; compute_cp_distance_circles() ;
Point3D position(trilaterate()) ; Point3D position(trilaterate()) ;
return Result(request, name, position) ; return Result(request, name, position) ;
} }
void TrilaterationAlgorithm::compute_ap_distance_circles() void TrilaterationAlgorithm::compute_cp_distance_circles()
{ {
ap_distances.clear() ; cp_distances.clear() ;
const unordered_map<string, Measurement> &measurements = const unordered_map<string, Measurement> &measurements =
request->get_measurements() ; request->get_measurements() ;
for (unordered_map<string, Measurement>::const_iterator i = for (unordered_map<string, Measurement>::const_iterator i =
measurements.begin() ; i != measurements.end() ; ++i) measurements.begin() ; i != measurements.end() ; ++i)
ap_distances[i->second.get_ap()] = estimate_distance(i->second) ; cp_distances[i->second.get_cp()] = estimate_distance(i->second) ;
} }

View File

@ -24,13 +24,13 @@ class TrilaterationAlgorithm: public virtual PositioningAlgorithm
protected: protected:
const Request *request ; const Request *request ;
std::unordered_map<AccessPoint*, float> ap_distances ; std::unordered_map<CapturePoint*, float> cp_distances ;
TrilaterationMethod *trilateration_method ; TrilaterationMethod *trilateration_method ;
/** @name Operations */ /** @name Operations */
//@{ //@{
double make_constant_term(const Measurement &measurement) ; double make_constant_term(const Measurement &measurement) ;
void compute_ap_distance_circles() ; void compute_cp_distance_circles() ;
Point3D trilaterate() ; Point3D trilaterate() ;
Point3D trilaterate_2d(float z) ; Point3D trilaterate_2d(float z) ;
//@} //@}
@ -51,13 +51,13 @@ public:
inline Point3D TrilaterationAlgorithm::trilaterate() inline Point3D TrilaterationAlgorithm::trilaterate()
{ {
return trilateration_method->trilaterate(ap_distances) ; return trilateration_method->trilaterate(cp_distances) ;
} }
inline Point3D TrilaterationAlgorithm::trilaterate_2d(float z) inline Point3D TrilaterationAlgorithm::trilaterate_2d(float z)
{ {
return trilateration_method->trilaterate_2d(ap_distances, z) ; return trilateration_method->trilaterate_2d(cp_distances, z) ;
} }

View File

@ -15,7 +15,7 @@
#ifndef _OWLPS_POSITIONING_TRILATERATIONMETHOD_HH_ #ifndef _OWLPS_POSITIONING_TRILATERATIONMETHOD_HH_
#define _OWLPS_POSITIONING_TRILATERATIONMETHOD_HH_ #define _OWLPS_POSITIONING_TRILATERATIONMETHOD_HH_
class AccessPoint ; class CapturePoint ;
#include "point3d.hh" #include "point3d.hh"
@ -23,7 +23,7 @@ class AccessPoint ;
/// Super-class of all trilateration methods /// Super-class of all trilateration methods
/** /**
* The source data is a list of access points associated with the * The source data is a list of capture points associated with the
* distances to the mobile. These distances are estimated using a * distances to the mobile. These distances are estimated using a
* TrilaterationAlgorithm. * TrilaterationAlgorithm.
*/ */
@ -35,11 +35,11 @@ public:
/// Selects a point in 3D space /// Selects a point in 3D space
virtual Point3D trilaterate( virtual Point3D trilaterate(
const std::unordered_map<AccessPoint*, float> &ap_distances) = 0 ; const std::unordered_map<CapturePoint*, float> &cp_distances) = 0 ;
/// Selects a point in 2D space, given its vertical coordinate (z) /// Selects a point in 2D space, given its vertical coordinate (z)
virtual Point3D trilaterate_2d( virtual Point3D trilaterate_2d(
const std::unordered_map<AccessPoint*, float> &ap_distances, const std::unordered_map<CapturePoint*, float> &cp_distances,
float z) = 0 ; float z) = 0 ;
} ; } ;

View File

@ -128,14 +128,14 @@ void UserInterface::fill_data_input_options()
po::options_description options("Data input options") ; po::options_description options("Data input options") ;
options.add_options() options.add_options()
("data-input.ap-medium", ("data-input.cp-medium",
po::value< vector<string> >()->composing(), po::value< vector<string> >()->composing(),
"Medium from which access points are read. You can specify this" "Medium from which capture points are read. You can specify this"
" option more than once. Allowed: CSV.") " option more than once. Allowed: CSV.")
("data-input.ap-csv-file", ("data-input.cp-csv-file",
po::value<string>(), po::value<string>(),
"CSV file to use for access points input (when" "CSV file to use for capture points input (when"
" data-input.ap-medium = CSV).") " data-input.cp-medium = CSV).")
("data-input.mobile-medium", ("data-input.mobile-medium",
po::value< vector<string> >()->composing(), po::value< vector<string> >()->composing(),
"Medium from which mobiles are read. You can specify this" "Medium from which mobiles are read. You can specify this"
@ -223,15 +223,15 @@ void UserInterface::fill_positioning_options()
po::value<bool>()->default_value(false), po::value<bool>()->default_value(false),
"When receiving requests, add unknown mobiles (mobiles which are not" "When receiving requests, add unknown mobiles (mobiles which are not"
" declared in the mobiles' configuration file) to the mobiles' list.") " declared in the mobiles' configuration file) to the mobiles' list.")
("positioning.accept-new-aps", ("positioning.accept-new-cps",
po::value<bool>()->default_value(false), po::value<bool>()->default_value(false),
"When receiving requests, add unknown APs (APs which are not" "When receiving requests, add unknown CPs (CPs which are not"
" declared in the APs' configuration file) to the APs' list" " declared in the CPs' configuration file) to the CPs' list"
" (default is false, for security purposes).") " (default is false, for security purposes).")
("positioning.update-ap-coordinates-online", ("positioning.update-cp-coordinates-online",
po::value<bool>()->default_value(false), po::value<bool>()->default_value(false),
"Allow AP's coordinates to be updated when a calibration request" "Allow CP's coordinates to be updated when a calibration request"
" with new coordinates is received from the AP (default is false," " with new coordinates is received from the CP (default is false,"
" for security purposes).") " for security purposes).")
("positioning.area-start", ("positioning.area-start",
po::value<string>(), po::value<string>(),
@ -310,10 +310,10 @@ void UserInterface::fill_positioning_options()
" before to compute the SS similarity." " before to compute the SS similarity."
" The default is false, i.e the positioning request is compared" " The default is false, i.e the positioning request is compared"
" directly to each calibration request.") " directly to each calibration request.")
("positioning.nss.ignore-ap-reference-points", ("positioning.nss.ignore-cp-reference-points",
po::value<bool>()->default_value(false), po::value<bool>()->default_value(false),
"With the NSS algorithm, try to avoid selecting the reference" "With the NSS algorithm, try to avoid selecting the reference"
" points which are coordinates of an AP.") " points which are coordinates of a CP.")
; ;
file_options->add(options) ; file_options->add(options) ;