[Positioner] New option filter.cp-reset-distance

The new option positioning.filter.cp-reset-distance allows to disable
the filter when the unfiltered location of the mobile terminal is found
to be close enough to a capture point.
This commit is contained in:
Matteo Cypriani 2014-05-14 17:04:44 -04:00
parent 36cf7c13cb
commit a1c8e0a093
3 changed files with 53 additions and 14 deletions

View File

@ -257,6 +257,16 @@ mobile-csv-file = /usr/local/etc/owlps/mobiles.csv
# This option also controls the activation of the filter (0 = disabled).
#max-speed = 0
# With this option set to a positive number, the filtering is temporary
# disabled when the mobile terminal is found to be close enough to a
# capture point. This option determines this "close enough" distance, in
# metres.
# This is useful in deployments where the system is much more accurate
# when the mobile is close to a capture point, such as underground
# mining tunnels; in such environments, 15 m appears to be a reasonable
# value to start experimenting.
#cp-reset-distance = 0
[output]
# The following options are related to the output of the results.

View File

@ -194,34 +194,63 @@ void Positioning::loop()
*/
void Positioning::filter(const Request &request, Result &result)
{
// Don't apply filter if filtering is disabled
/* Don't apply filter if filtering is disabled */
float max_speed =
Configuration::float_value("positioning.filter.max-speed") ;
if (max_speed <= 0)
return ;
// Don't apply filter if it is the first result we compute for this
// mobile (hence we don't have previous results to compare to)
/* Don't apply filter if it is the first result we compute for this
* mobile (hence we don't have previous results to compare to) */
const Mobile *const mobile = request.get_mobile() ;
const ResultList &last_results = mobile->get_last_results() ;
if(last_results.empty())
return ;
// Don't apply filter if the "algorithm" is the real position
/* Don't apply filter if the "algorithm" is the real position */
string algo_name = result.get_algorithm() ;
if (algo_name == "Real")
return ;
/* Print the common message in verbose mode */
const Timestamp &timestamp = result.get_request()->get_time_sent() ;
if (Configuration::is_configured("verbose"))
cerr
<< "Filtering (algorithm " << algo_name << "): "
<< "for request sent at " << timestamp
<< " by mobile " << mobile->get_mac_addr() << ", " ;
/* Don't apply filter if the reset distance is configured and the
* mobile is within this distance */
// Get the unfiltered coordinates:
const Point3D &pos = result.get_position() ;
float reset_distance =
Configuration::float_value("positioning.filter.cp-reset-distance") ;
if (reset_distance > 0)
{
float dist_closest_cp = Stock::distance_from_closest_cp(pos) ;
assert(dist_closest_cp >= 0) ;
if (dist_closest_cp <= reset_distance)
{
if (Configuration::is_configured("verbose"))
cerr
<< "the mobile appears to be within the reset distance"
<< " of " << reset_distance
<< " m from a CP; no filtering.\n" ;
return ;
}
}
/* Okay, now let's get to it! */
const Result &prev_result = last_results.get_result_for_algo(algo_name) ;
// Calculate the travel time (duration)
const Timestamp &timestamp = result.get_request()->get_time_sent() ;
const Timestamp &prev_timestamp =
last_results.get_request()->get_time_sent() ;
Timestamp duration = prev_timestamp.elapsed(timestamp) ;
// Get the current and previous coordinates
const Point3D &pos = result.get_position() ;
// Get the previous coordinates
const Point3D &prev_pos = prev_result.get_position() ;
// Recompute the result by interpolation
@ -229,13 +258,9 @@ void Positioning::filter(const Request &request, Result &result)
if (filtered_pos != pos)
{
if (Configuration::is_configured("verbose"))
cerr
<< "Filtering (algorithm " << algo_name << "): "
<< "for request sent at " << timestamp
<< " by mobile " << mobile->get_mac_addr()
<< ", " << pos
<< " was replaced by " << filtered_pos
<< ".\n" ;
cerr << pos << " was replaced by " << filtered_pos << ".\n" ;
result.set_position(filtered_pos) ;
}
else if (Configuration::is_configured("verbose"))
cerr << "the original position looked good enough and was kept.\n" ;
}

View File

@ -332,6 +332,10 @@ void UserInterface::fill_positioning_options()
po::value<float>()->default_value(0),
"Maximal speed at which the mobiles can move, in km/h (0 = unlimited"
" speed).")
("positioning.filter.cp-reset-distance",
po::value<float>()->default_value(0),
"Disable filtering when the computed position is at this distance (in"
" m) from a CP or closer (0 = never disable filtering).")
;
file_options->add(options) ;