mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-14 04:43:33 +08:00
run_seconds
This commit is contained in:
committed by
Mathieu Bresciani
parent
39b369d90b
commit
1832bedd13
+1
-1
@@ -44,6 +44,6 @@ set(SRCS
|
||||
)
|
||||
add_executable(ECL_GTESTS ${SRCS})
|
||||
|
||||
target_link_libraries(ECL_GTESTS gtest_main ecl_EKF SENSOR_SIMULATOR)
|
||||
target_link_libraries(ECL_GTESTS gtest_main ecl_EKF ecl_sensor_sim)
|
||||
|
||||
add_test(NAME ECL_GTESTS COMMAND ECL_GTESTS)
|
||||
|
||||
@@ -41,5 +41,5 @@ set(SRCS
|
||||
gps.cpp
|
||||
)
|
||||
|
||||
add_library(SENSOR_SIMULATOR ${SRCS})
|
||||
target_link_libraries(SENSOR_SIMULATOR ecl_EKF)
|
||||
add_library(ecl_sensor_sim ${SRCS})
|
||||
target_link_libraries(ecl_sensor_sim ecl_EKF)
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
private:
|
||||
float _baro_data;
|
||||
|
||||
void send(uint32_t time);
|
||||
void send(uint32_t time) override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
private:
|
||||
gps_message _gps_data;
|
||||
|
||||
void send(uint32_t time);
|
||||
void send(uint32_t time) override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ private:
|
||||
Vector3f _accel_data;
|
||||
Vector3f _gyro_data;
|
||||
|
||||
void send(uint32_t time);
|
||||
void send(uint32_t time) override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
private:
|
||||
Vector3f _mag_data;
|
||||
|
||||
void send(uint32_t time);
|
||||
void send(uint32_t time) override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -58,7 +58,12 @@ gps_message SensorSimulator::getDefaultGpsData()
|
||||
return gps_data;
|
||||
}
|
||||
|
||||
void SensorSimulator::run(uint32_t duration)
|
||||
void SensorSimulator::run_seconds(float duration_seconds)
|
||||
{
|
||||
run_microseconds( uint32_t(duration_seconds * 1e6f) );
|
||||
}
|
||||
|
||||
void SensorSimulator::run_microseconds(uint32_t duration)
|
||||
{
|
||||
// simulate in 1000us steps
|
||||
uint32_t start_time = _time;
|
||||
|
||||
@@ -63,7 +63,8 @@ public:
|
||||
void setBaroRate(uint32_t rate){ _baro.setRate(rate); }
|
||||
void setGpsRate(uint32_t rate){ _gps.setRate(rate); }
|
||||
|
||||
void run(uint32_t duration);
|
||||
void run_seconds(float duration_seconds);
|
||||
void run_microseconds(uint32_t duration);
|
||||
|
||||
void startGps(){ _gps.start(); }
|
||||
void stopGps(){ _gps.stop(); }
|
||||
|
||||
@@ -48,13 +48,13 @@ class EkfInitializationTest : public ::testing::Test {
|
||||
SensorSimulator _sensor_simulator;
|
||||
|
||||
// Duration of initalization with only providing baro,mag and IMU
|
||||
const uint32_t _init_duration_us{2000000}; // 2s
|
||||
const uint32_t _init_duration_s{2};
|
||||
|
||||
// Setup the Ekf with synthetic measurements
|
||||
void SetUp() override
|
||||
{
|
||||
_ekf->init(0);
|
||||
_sensor_simulator.run(_init_duration_us);
|
||||
_sensor_simulator.run_seconds(_init_duration_s);
|
||||
}
|
||||
|
||||
// Use this method to clean up any memory, network etc. after each test
|
||||
@@ -107,9 +107,8 @@ TEST_F(EkfInitializationTest, initialControlMode)
|
||||
|
||||
TEST_F(EkfInitializationTest, convergesToZero)
|
||||
{
|
||||
// GIVEN: initialized EKF with default IMU, baro and mag input for 2s
|
||||
// WHEN: Added more defautl sensor measurements
|
||||
_sensor_simulator.run(4000000); // for further 4s
|
||||
// GIVEN: initialized EKF with default IMU, baro and mag input
|
||||
_sensor_simulator.run_seconds(4);
|
||||
|
||||
float converged_pos[3];
|
||||
float converged_vel[3];
|
||||
@@ -132,11 +131,11 @@ TEST_F(EkfInitializationTest, convergesToZero)
|
||||
|
||||
TEST_F(EkfInitializationTest, gpsFusion)
|
||||
{
|
||||
// GIVEN: initialized EKF with default IMU, baro and mag input for 2s
|
||||
// GIVEN: initialized EKF with default IMU, baro and mag input for
|
||||
// WHEN: setting GPS measurements for 11s, minimum GPS health time is set to 10 sec
|
||||
|
||||
_sensor_simulator.startGps();
|
||||
_sensor_simulator.run(11000000); // for further 3s
|
||||
_sensor_simulator.run_seconds(11);
|
||||
|
||||
// THEN: EKF should fuse GPS, but no other position sensor
|
||||
filter_control_status_u control_status;
|
||||
@@ -176,7 +175,7 @@ TEST_F(EkfInitializationTest, accleBiasEstimation)
|
||||
|
||||
_sensor_simulator.startGps();
|
||||
_sensor_simulator.setImuBias(accel_bias, Vector3f{0.0f,0.0f,0.0f});
|
||||
_sensor_simulator.run(10000000);
|
||||
_sensor_simulator.run_seconds(10);
|
||||
|
||||
float converged_pos[3];
|
||||
float converged_vel[3];
|
||||
|
||||
Reference in New Issue
Block a user