|
|
|
@ -41,18 +41,13 @@
@@ -41,18 +41,13 @@
|
|
|
|
|
|
|
|
|
|
class EkfBasicsTest : public ::testing::Test { |
|
|
|
|
public: |
|
|
|
|
EkfBasicsTest(): ::testing::Test(), |
|
|
|
|
_ekf{std::make_shared<Ekf>()}, |
|
|
|
|
_sensor_simulator(_ekf), |
|
|
|
|
_ekf_wrapper(_ekf) {}; |
|
|
|
|
|
|
|
|
|
std::shared_ptr<Ekf> _ekf; |
|
|
|
|
SensorSimulator _sensor_simulator; |
|
|
|
|
EkfWrapper _ekf_wrapper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Duration of initalization with only providing baro,mag and IMU
|
|
|
|
|
const uint32_t _init_duration_s{7}; |
|
|
|
|
EkfBasicsTest(): |
|
|
|
|
::testing::Test(), |
|
|
|
|
_ekf{std::make_shared<Ekf>()}, |
|
|
|
|
_ekf_wrapper(_ekf) , |
|
|
|
|
_sensor_simulator(_ekf) |
|
|
|
|
{ |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// Setup the Ekf with synthetic measurements
|
|
|
|
|
void SetUp() override |
|
|
|
@ -65,6 +60,27 @@ class EkfBasicsTest : public ::testing::Test {
@@ -65,6 +60,27 @@ class EkfBasicsTest : public ::testing::Test {
|
|
|
|
|
void TearDown() override |
|
|
|
|
{ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::shared_ptr<Ekf> _ekf {nullptr}; |
|
|
|
|
EkfWrapper _ekf_wrapper; |
|
|
|
|
SensorSimulator _sensor_simulator; |
|
|
|
|
|
|
|
|
|
// Duration of initalization with only providing baro,mag and IMU
|
|
|
|
|
const uint32_t _init_duration_s{7}; |
|
|
|
|
|
|
|
|
|
protected: |
|
|
|
|
double _latitude {0.0}; |
|
|
|
|
double _longitude {0.0}; |
|
|
|
|
float _altitude {0.f}; |
|
|
|
|
|
|
|
|
|
double _latitude_new {0.0}; |
|
|
|
|
double _longitude_new {0.0}; |
|
|
|
|
float _altitude_new {0.f}; |
|
|
|
|
|
|
|
|
|
uint64_t _origin_time = 0; |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -188,56 +204,85 @@ TEST_F(EkfBasicsTest, accelBiasEstimation)
@@ -188,56 +204,85 @@ TEST_F(EkfBasicsTest, accelBiasEstimation)
|
|
|
|
|
<< "gyro_bias = " << gyro_bias(0) << ", " << gyro_bias(1) << ", " << gyro_bias(2); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_F(EkfBasicsTest, reset_ekf_global_origin) |
|
|
|
|
TEST_F(EkfBasicsTest, reset_ekf_global_origin_gps_initialized) |
|
|
|
|
{ |
|
|
|
|
double latitude {0.0}; |
|
|
|
|
double longitude {0.0}; |
|
|
|
|
float altitude {0.f}; |
|
|
|
|
|
|
|
|
|
double latitude_new {0.0}; |
|
|
|
|
double longitude_new {0.0}; |
|
|
|
|
float altitude_new {0.f}; |
|
|
|
|
|
|
|
|
|
uint64_t origin_time = 0; |
|
|
|
|
|
|
|
|
|
_ekf->getEkfGlobalOrigin(origin_time, latitude_new, longitude_new, altitude_new); |
|
|
|
|
|
|
|
|
|
EXPECT_DOUBLE_EQ(latitude, latitude_new); |
|
|
|
|
EXPECT_DOUBLE_EQ(longitude, longitude_new); |
|
|
|
|
EXPECT_FLOAT_EQ(altitude, altitude_new); |
|
|
|
|
_latitude_new = 15.0000005; |
|
|
|
|
_longitude_new = 115.0000005; |
|
|
|
|
_altitude_new = 100.0; |
|
|
|
|
|
|
|
|
|
_sensor_simulator.startGps(); |
|
|
|
|
_ekf->set_min_required_gps_health_time(1e6); |
|
|
|
|
_sensor_simulator.runSeconds(1); |
|
|
|
|
sleep(1); |
|
|
|
|
|
|
|
|
|
latitude_new = 45.0000005; |
|
|
|
|
longitude_new = -111.0000005; |
|
|
|
|
altitude_new = 1500.0; |
|
|
|
|
_sensor_simulator.setGpsLatitude(_latitude_new); |
|
|
|
|
_sensor_simulator.setGpsLongitude(_longitude_new); |
|
|
|
|
_sensor_simulator.setGpsAltitude(_altitude_new); |
|
|
|
|
_sensor_simulator.runSeconds(2); |
|
|
|
|
|
|
|
|
|
_ekf->setEkfGlobalOrigin(latitude_new, longitude_new, altitude_new); |
|
|
|
|
_ekf->getEkfGlobalOrigin(origin_time, latitude, longitude, altitude); |
|
|
|
|
_ekf->getEkfGlobalOrigin(_origin_time, _latitude, _longitude, _altitude); |
|
|
|
|
|
|
|
|
|
// EKF origin MSL altitude cannot be reset without valid MSL origin.
|
|
|
|
|
EXPECT_DOUBLE_EQ(latitude, latitude_new); |
|
|
|
|
EXPECT_DOUBLE_EQ(longitude, longitude_new); |
|
|
|
|
EXPECT_DOUBLE_EQ(_latitude, _latitude_new); |
|
|
|
|
EXPECT_DOUBLE_EQ(_longitude, _longitude_new); |
|
|
|
|
EXPECT_NEAR(_altitude, _altitude_new, 0.01f); |
|
|
|
|
|
|
|
|
|
// After the change of origin, the pos and vel innovations should stay small
|
|
|
|
|
_sensor_simulator.runSeconds(1); |
|
|
|
|
sleep(1); |
|
|
|
|
_latitude_new = -15.0000005; |
|
|
|
|
_longitude_new = -115.0000005; |
|
|
|
|
_altitude_new = 1500.0; |
|
|
|
|
|
|
|
|
|
_ekf->setEkfGlobalOrigin(_latitude_new, _longitude_new, _altitude_new); |
|
|
|
|
_ekf->getEkfGlobalOrigin(_origin_time, _latitude, _longitude, _altitude); |
|
|
|
|
|
|
|
|
|
EXPECT_DOUBLE_EQ(_latitude, _latitude_new); |
|
|
|
|
EXPECT_DOUBLE_EQ(_longitude, _longitude_new); |
|
|
|
|
EXPECT_FLOAT_EQ(_altitude, _altitude_new); |
|
|
|
|
|
|
|
|
|
float hpos = 0.f; |
|
|
|
|
float vpos = 0.f; |
|
|
|
|
float hvel = 0.f; |
|
|
|
|
float vvel = 0.f; |
|
|
|
|
|
|
|
|
|
// After the change of origin, the pos and vel innovations should stay small
|
|
|
|
|
_ekf->getGpsVelPosInnovRatio(hvel, vvel, hpos, vpos); |
|
|
|
|
|
|
|
|
|
EXPECT_NEAR(hpos, 0.f, 0.05f); |
|
|
|
|
EXPECT_NEAR(vpos, 0.f, 0.05f); |
|
|
|
|
|
|
|
|
|
EXPECT_NEAR(hvel, 0.f, 0.02f); |
|
|
|
|
EXPECT_NEAR(vvel, 0.f, 0.02f); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_F(EkfBasicsTest, reset_ekf_global_origin_gps_uninitialized) |
|
|
|
|
{ |
|
|
|
|
_ekf->getEkfGlobalOrigin(_origin_time, _latitude_new, _longitude_new, _altitude_new); |
|
|
|
|
|
|
|
|
|
EXPECT_DOUBLE_EQ(_latitude, _latitude_new); |
|
|
|
|
EXPECT_DOUBLE_EQ(_longitude, _longitude_new); |
|
|
|
|
EXPECT_FLOAT_EQ(_altitude, _altitude_new); |
|
|
|
|
|
|
|
|
|
_latitude_new = 45.0000005; |
|
|
|
|
_longitude_new = 111.0000005; |
|
|
|
|
_altitude_new = 1500.0; |
|
|
|
|
|
|
|
|
|
_ekf->setEkfGlobalOrigin(_latitude_new, _longitude_new, _altitude_new); |
|
|
|
|
_ekf->getEkfGlobalOrigin(_origin_time, _latitude, _longitude, _altitude); |
|
|
|
|
|
|
|
|
|
EXPECT_DOUBLE_EQ(_latitude, _latitude_new); |
|
|
|
|
EXPECT_DOUBLE_EQ(_longitude, _longitude_new); |
|
|
|
|
EXPECT_FLOAT_EQ(_altitude, _altitude_new); |
|
|
|
|
|
|
|
|
|
float hpos = 0.f; |
|
|
|
|
float vpos = 0.f; |
|
|
|
|
float hvel = 0.f; |
|
|
|
|
float vvel = 0.f; |
|
|
|
|
|
|
|
|
|
// After the change of origin, the pos and vel innovations should stay small
|
|
|
|
|
_ekf->getGpsVelPosInnovRatio(hvel, vvel, hpos, vpos); |
|
|
|
|
|
|
|
|
|
EXPECT_NEAR(hpos, 0.f, 0.05f); |
|
|
|
|
EXPECT_NEAR(vpos, 0.f, 0.05f); |
|
|
|
|
|
|
|
|
|
EXPECT_NEAR(hvel, 0.f, 0.02f); |
|
|
|
|
EXPECT_NEAR(vvel, 0.f, 0.02f); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// TODO: Add sampling tests
|
|
|
|
|