2017-08-22 18:32:39 -04:00
|
|
|
#include <unit_test.h>
|
2016-07-29 13:27:58 +02:00
|
|
|
|
|
|
|
|
#include <drivers/drv_hrt.h>
|
|
|
|
|
#include <geo/geo.h>
|
|
|
|
|
#include <px4iofirmware/px4io.h>
|
|
|
|
|
#include <systemlib/err.h>
|
|
|
|
|
#include <systemlib/mixer/mixer.h>
|
|
|
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
|
|
class AutoDeclinationTest : public UnitTest
|
|
|
|
|
{
|
|
|
|
|
public:
|
2017-01-28 20:49:47 -05:00
|
|
|
virtual bool run_tests();
|
2016-07-29 13:27:58 +02:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
bool autodeclination_check();
|
|
|
|
|
};
|
|
|
|
|
|
2017-01-28 20:49:47 -05:00
|
|
|
bool AutoDeclinationTest::autodeclination_check()
|
2016-07-29 13:27:58 +02:00
|
|
|
{
|
2017-02-02 15:27:21 -08:00
|
|
|
ut_assert("declination differs more than 0.1 degrees", get_mag_declination(47.0, 8.0) - 1.6f < 0.1f);
|
|
|
|
|
// Test world endpoints
|
|
|
|
|
ut_assert("declination differs more than 0.1 degrees", get_mag_declination(-90.0, 180.0) - 47.0f < 0.1f);
|
|
|
|
|
ut_assert("declination differs more than 0.1 degrees", get_mag_declination(-90.0, -180.0) - 47.0f < 0.1f);
|
|
|
|
|
ut_assert("declination differs more than 0.1 degrees", get_mag_declination(90.0, -180.0) - 3.0f < 0.1f);
|
|
|
|
|
ut_assert("declination differs more than 0.1 degrees", get_mag_declination(90.0, 180.0) - 3.0f < 0.1f);
|
2016-07-29 13:27:58 +02:00
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-28 20:49:47 -05:00
|
|
|
bool AutoDeclinationTest::run_tests()
|
2016-07-29 13:27:58 +02:00
|
|
|
{
|
|
|
|
|
ut_run_test(autodeclination_check);
|
|
|
|
|
|
|
|
|
|
return (_tests_failed == 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ut_declare_test_c(test_autodeclination, AutoDeclinationTest)
|