|
|
@ -40,6 +40,7 @@ |
|
|
|
#include "EKF/ekf.h" |
|
|
|
#include "EKF/ekf.h" |
|
|
|
#include "sensor_simulator/sensor_simulator.h" |
|
|
|
#include "sensor_simulator/sensor_simulator.h" |
|
|
|
#include "sensor_simulator/ekf_wrapper.h" |
|
|
|
#include "sensor_simulator/ekf_wrapper.h" |
|
|
|
|
|
|
|
#include "test_helper/reset_logging_checker.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class EkfFusionLogicTest : public ::testing::Test |
|
|
|
class EkfFusionLogicTest : public ::testing::Test |
|
|
@ -344,7 +345,9 @@ TEST_F(EkfFusionLogicTest, doVisionHeadingFusion) |
|
|
|
|
|
|
|
|
|
|
|
TEST_F(EkfFusionLogicTest, doBaroHeightFusion) |
|
|
|
TEST_F(EkfFusionLogicTest, doBaroHeightFusion) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// GIVEN: EKF that receives baro data
|
|
|
|
// GIVEN: EKF that receives baro and GPS data
|
|
|
|
|
|
|
|
_sensor_simulator.startGps(); |
|
|
|
|
|
|
|
_sensor_simulator.runSeconds(11); |
|
|
|
|
|
|
|
|
|
|
|
// THEN: EKF should intend to fuse baro by default
|
|
|
|
// THEN: EKF should intend to fuse baro by default
|
|
|
|
EXPECT_TRUE(_ekf_wrapper.isIntendingBaroHeightFusion()); |
|
|
|
EXPECT_TRUE(_ekf_wrapper.isIntendingBaroHeightFusion()); |
|
|
@ -353,11 +356,49 @@ TEST_F(EkfFusionLogicTest, doBaroHeightFusion) |
|
|
|
_sensor_simulator.stopBaro(); |
|
|
|
_sensor_simulator.stopBaro(); |
|
|
|
_sensor_simulator.runSeconds(6); |
|
|
|
_sensor_simulator.runSeconds(6); |
|
|
|
|
|
|
|
|
|
|
|
// THEN: EKF should stop to intend to use baro hgt
|
|
|
|
// THEN: EKF should stop to intend to use baro hgt and use GPS as a fallback
|
|
|
|
// TODO: We have no fall back in balce
|
|
|
|
EXPECT_FALSE(_ekf_wrapper.isIntendingBaroHeightFusion()); |
|
|
|
EXPECT_TRUE(_ekf_wrapper.isIntendingBaroHeightFusion()); // TODO: Needs to change
|
|
|
|
EXPECT_TRUE(_ekf_wrapper.isIntendingGpsHeightFusion()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(EkfFusionLogicTest, doBaroHeightFusionTimeout) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// GIVEN: EKF that receives baro data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// THEN: EKF should intend to fuse baro by default
|
|
|
|
|
|
|
|
EXPECT_TRUE(_ekf_wrapper.isIntendingBaroHeightFusion()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// WHEN: the baro data jumps by a lot
|
|
|
|
|
|
|
|
ResetLoggingChecker reset_logging_checker(_ekf); |
|
|
|
|
|
|
|
reset_logging_checker.capturePreResetState(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_sensor_simulator._baro.setData(100.f); |
|
|
|
|
|
|
|
_sensor_simulator.runSeconds(6); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
reset_logging_checker.capturePostResetState(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// THEN: EKF should reset to the measurement
|
|
|
|
|
|
|
|
EXPECT_TRUE(_ekf_wrapper.isIntendingBaroHeightFusion()); |
|
|
|
|
|
|
|
EXPECT_TRUE(reset_logging_checker.isVerticalVelocityResetCounterIncreasedBy(1)); |
|
|
|
|
|
|
|
EXPECT_TRUE(reset_logging_checker.isVerticalPositionResetCounterIncreasedBy(1)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// BUT WHEN: GPS height data is also available
|
|
|
|
|
|
|
|
_sensor_simulator.startGps(); |
|
|
|
|
|
|
|
_sensor_simulator.runSeconds(11); |
|
|
|
|
|
|
|
reset_logging_checker.capturePostResetState(); |
|
|
|
|
|
|
|
EXPECT_TRUE(reset_logging_checker.isVerticalVelocityResetCounterIncreasedBy(2)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// AND: the baro data jumps by a lot
|
|
|
|
|
|
|
|
_sensor_simulator._baro.setData(800.f); |
|
|
|
|
|
|
|
_sensor_simulator.runSeconds(6); |
|
|
|
|
|
|
|
reset_logging_checker.capturePostResetState(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// THEN: EKF should fallback to GPS height
|
|
|
|
|
|
|
|
EXPECT_FALSE(_ekf_wrapper.isIntendingBaroHeightFusion()); |
|
|
|
|
|
|
|
EXPECT_TRUE(_ekf_wrapper.isIntendingGpsHeightFusion()); |
|
|
|
|
|
|
|
EXPECT_TRUE(reset_logging_checker.isVerticalVelocityResetCounterIncreasedBy(3)); |
|
|
|
|
|
|
|
EXPECT_TRUE(reset_logging_checker.isVerticalPositionResetCounterIncreasedBy(2)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
TEST_F(EkfFusionLogicTest, doGpsHeightFusion) |
|
|
|
TEST_F(EkfFusionLogicTest, doGpsHeightFusion) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -371,13 +412,13 @@ TEST_F(EkfFusionLogicTest, doGpsHeightFusion) |
|
|
|
|
|
|
|
|
|
|
|
// WHEN: stop sending gps data
|
|
|
|
// WHEN: stop sending gps data
|
|
|
|
_sensor_simulator.stopGps(); |
|
|
|
_sensor_simulator.stopGps(); |
|
|
|
_sensor_simulator.runSeconds(11); // TODO: We have to wait way too long
|
|
|
|
_sensor_simulator.runSeconds(5); |
|
|
|
|
|
|
|
|
|
|
|
// THEN: EKF should stop to intend to use gps height
|
|
|
|
// THEN: EKF should stop to intend to use gps height
|
|
|
|
EXPECT_FALSE(_ekf_wrapper.isIntendingGpsHeightFusion()); |
|
|
|
EXPECT_FALSE(_ekf_wrapper.isIntendingGpsHeightFusion()); |
|
|
|
|
|
|
|
EXPECT_TRUE(_ekf_wrapper.isIntendingBaroHeightFusion()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(EkfFusionLogicTest, doRangeHeightFusion) |
|
|
|
TEST_F(EkfFusionLogicTest, doRangeHeightFusion) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// WHEN: commanding range height and sending range data
|
|
|
|
// WHEN: commanding range height and sending range data
|
|
|
|