[Positioner] Autocalib.: weight angle/coverage

In Stock::generate_reference_point(), the coverage percentage is now
used along the angle to select the better APs.
This commit is contained in:
Matteo Cypriani 2011-12-29 17:09:25 +01:00
parent 5f26d7a28e
commit 427c88fd99
1 changed files with 17 additions and 9 deletions

View File

@ -513,23 +513,31 @@ void Stock::generate_reference_point(const Point3D &point)
/* Choose the 2 nearest APs in angle */
const Point3D &rx_coord = rx->second.get_coordinates() ;
multimap<double,
unordered_map<string, AccessPoint>::const_iterator>
multimap<double, pair<double,
unordered_map<string, AccessPoint>::const_iterator> >
sorted_angles ;
for (unordered_map<string, AccessPoint>::const_iterator
ref = aps.begin() ; ref != aps.end() ; ++ref)
{
if (ref == rx)
continue ;
float coverage =
rx->second.received_calibration_from_ap(ref->second) ;
// Skip the AP if it is not in coverage with the receiver AP:
if (! rx->second.received_calibration_from_ap(ref->second))
if (coverage < 1) // Less than 1% coverage is ridiculous!
continue ;
double angle =
rx_coord.angle(point, ref->second.get_coordinates()) ;
double weight = angle / coverage ;
pair<double,
unordered_map<string, AccessPoint>::const_iterator>
angle_ap(angle, ref) ;
sorted_angles.insert(angle_ap) ;
pair<double, pair<double,
unordered_map<string, AccessPoint>::const_iterator> >
weight_angle_ap(weight, angle_ap) ;
sorted_angles.insert(weight_angle_ap) ;
}
if (sorted_angles.size() < 2)
@ -541,14 +549,14 @@ void Stock::generate_reference_point(const Point3D &point)
}
/* Compute the angle weight of the 2 reference APs */
map<double,
unordered_map<string, AccessPoint>::const_iterator>
map<double, pair<double,
unordered_map<string, AccessPoint>::const_iterator> >
::const_iterator s = sorted_angles.begin() ;
// Angle REF1-RX-P
double ref1_angle = s->first ;
const AccessPoint &ref1 = s->second->second ;
double ref1_angle = s->second.first ;
const AccessPoint &ref1 = s->second.second->second ;
++s ;
const AccessPoint &ref2 = s->second->second ;
const AccessPoint &ref2 = s->second.second->second ;
// Angle REF1-RX-REF2
const Point3D &ref1_coord = ref1.get_coordinates() ;