[Positioner] Autocalibration: APs in coverage
In Stock::generate_reference_point(), we now select an AP only if it is in coverage of the reference AP.
This commit is contained in:
parent
d683c32ce5
commit
9c1fc429c9
|
@ -6,9 +6,11 @@
|
|||
|
||||
|
||||
#include "accesspoint.hh"
|
||||
|
||||
#include "stock.hh"
|
||||
#include "posexcept.hh"
|
||||
|
||||
using namespace std ;
|
||||
using std::tr1::unordered_map ;
|
||||
|
||||
|
||||
|
||||
|
@ -23,6 +25,44 @@ double AccessPoint::friis_constant_term() const
|
|||
}
|
||||
|
||||
|
||||
bool AccessPoint::
|
||||
received_calibration_from_ap(const AccessPoint &trx) const
|
||||
{
|
||||
if (this == &trx)
|
||||
return true ;
|
||||
|
||||
// If no reference point is associated with trx, no AP received
|
||||
// any calibration from it:
|
||||
const ReferencePoint *ref_trx ;
|
||||
try
|
||||
{
|
||||
ref_trx = &Stock::get_reference_point(trx.coordinates) ;
|
||||
}
|
||||
catch (element_not_found &e)
|
||||
{
|
||||
return false ;
|
||||
}
|
||||
|
||||
// Check if trx sent a calibration request:
|
||||
const vector<CalibrationRequest*> &ref_requests =
|
||||
ref_trx->get_requests(trx.mac_addr) ;
|
||||
if (ref_requests.empty())
|
||||
return false ;
|
||||
|
||||
// Check if the AP received at least one message sent by trx:
|
||||
for (vector<CalibrationRequest*>::const_iterator cr =
|
||||
ref_requests.begin() ; cr != ref_requests.end() ; ++cr)
|
||||
{
|
||||
const vector<const Measurement*> &measurements =
|
||||
(*cr)->get_measurements(mac_addr) ;
|
||||
if (! measurements.empty())
|
||||
return true ;
|
||||
}
|
||||
|
||||
return false ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* *** Operators *** */
|
||||
|
||||
|
|
|
@ -78,6 +78,8 @@ public:
|
|||
//@{
|
||||
/// Returns the Friis formula's constant term
|
||||
double friis_constant_term(void) const ;
|
||||
/// Checks if the AP received calibration packets from \em trx
|
||||
bool received_calibration_from_ap(const AccessPoint &trx) const ;
|
||||
//@}
|
||||
|
||||
/** @name Operators */
|
||||
|
|
|
@ -512,8 +512,7 @@ void Stock::generate_reference_point(const Point3D &point)
|
|||
vmob_pow += rx->second.get_trx_power() / aps.size() ;
|
||||
|
||||
/* Choose the 2 nearest APs in angle */
|
||||
const Point3D &rx_coord =
|
||||
rx->second.get_coordinates() ;
|
||||
const Point3D &rx_coord = rx->second.get_coordinates() ;
|
||||
multimap<double,
|
||||
unordered_map<string, AccessPoint>::const_iterator>
|
||||
sorted_angles ;
|
||||
|
@ -522,20 +521,24 @@ void Stock::generate_reference_point(const Point3D &point)
|
|||
{
|
||||
if (ref == rx)
|
||||
continue ;
|
||||
const Point3D &ref_coord =
|
||||
ref->second.get_coordinates() ;
|
||||
// Skip the AP if the associated reference point does
|
||||
// not exist yet:
|
||||
if (! reference_point_exists(ref_coord))
|
||||
// Skip the AP if it is not in coverage with the receiver AP:
|
||||
if (! rx->second.received_calibration_from_ap(ref->second))
|
||||
continue ;
|
||||
double angle =
|
||||
rx_coord.angle(point, ref_coord) ;
|
||||
rx_coord.angle(point, ref->second.get_coordinates()) ;
|
||||
pair<double,
|
||||
unordered_map<string, AccessPoint>::const_iterator>
|
||||
angle_ap(angle, ref) ;
|
||||
sorted_angles.insert(angle_ap) ;
|
||||
}
|
||||
assert(sorted_angles.size() > 1) ;
|
||||
|
||||
if (sorted_angles.size() < 2)
|
||||
{
|
||||
if (Configuration::is_configured("verbose"))
|
||||
cerr << "Can't generate reference point, not enough APs"
|
||||
<< " in coverage!\n" ;
|
||||
return ;
|
||||
}
|
||||
|
||||
/* Compute the angle weight of the 2 reference APs */
|
||||
map<double,
|
||||
|
|
Loading…
Reference in New Issue