owlps/owlps-positioner/tests/interlinknetworks_test.hh

47 lines
1.2 KiB
C++

#include <cxxtest/TestSuite.h>
#include "interlinknetworks.hh"
class InterlinkNetworks_test: public CxxTest::TestSuite
{
public:
void test_distance(void)
{
TrilaterationAlgorithm *algo = new InterlinkNetworks() ;
// Initialise algo->request
float mobile_gain = 3, mobile_power = 15 ;
Mobile mobile("", "", mobile_gain, mobile_power) ;
Request request(&mobile) ;
algo->compute(request) ; // yes, that's ugly
float ap_gain = 5, ap_power = 20 ;
unsigned int ap_channel = 1 ;
CapturePoint ap(Point3D(), "", "", ap_gain, ap_power, ap_channel) ;
std::map<pkt_id_t, ss_t> ss_list ;
ss_list[1] = -42 ;
Measurement measurement(&ap) ;
measurement.add_ss_list(ss_list) ;
/* To check ref_distance in Scilab:
mobile_gain = 3
mobile_power = 15
ap_gain = 5
celerity = 299792458
frequency = 2412000000
C = mobile_gain + mobile_power + ap_gain + 20 * log10(celerity / frequency / (4 * %pi))
L = -42
ref_distance = 10^((C-L)/35)
*/
float ref_distance = 5.1470931 ;
float computed_distance = algo->estimate_distance(measurement) ;
TS_ASSERT_DELTA(computed_distance, ref_distance, 0.0001) ;
delete algo ;
}
} ;