@ -196,6 +196,7 @@ void ReplayVehicle::setup(void)
@@ -196,6 +196,7 @@ void ReplayVehicle::setup(void)
ahrs . set_wind_estimation ( true ) ;
ahrs . set_correct_centrifugal ( true ) ;
ahrs . set_ekf_use ( true ) ;
EKF2 . set_enable ( true ) ;
printf ( " Starting disarmed \n " ) ;
@ -228,7 +229,9 @@ public:
@@ -228,7 +229,9 @@ public:
*/
struct log_information {
uint16_t update_rate ;
bool have_imu2 ;
bool have_imu2 : 1 ;
bool have_imt : 1 ;
bool have_imt2 : 1 ;
} log_info { } ;
private :
@ -253,9 +256,6 @@ private:
@@ -253,9 +256,6 @@ private:
bool done_home_init ;
int32_t arm_time_ms = - 1 ;
bool ahrs_healthy ;
bool have_imt = false ;
bool have_imt2 = false ;
bool have_fram = false ;
bool use_imt = true ;
bool check_generate = false ;
float tolerance_euler = 3 ;
@ -552,9 +552,15 @@ bool Replay::find_log_info(struct log_information &info)
@@ -552,9 +552,15 @@ bool Replay::find_log_info(struct log_information &info)
}
}
if ( streq ( type , " IMU2 " ) & & ! info . have_imu2 ) {
if ( streq ( type , " IMU2 " ) ) {
info . have_imu2 = true ;
}
if ( streq ( type , " IMT " ) ) {
info . have_imt = true ;
}
if ( streq ( type , " IMT2 " ) ) {
info . have_imt2 = true ;
}
}
if ( smallest_delta = = 0 ) {
: : printf ( " Unable to determine log rate - insufficient IMU/IMT messages? (need=%d got=%d) " , samples_required , samplecount ) ;
@ -623,6 +629,17 @@ void Replay::setup()
@@ -623,6 +629,17 @@ void Replay::setup()
_vehicle . setup ( ) ;
inhibit_gyro_cal ( ) ;
if ( log_info . update_rate = = 400 ) {
// assume copter for 400Hz
_vehicle . ahrs . set_vehicle_class ( AHRS_VEHICLE_COPTER ) ;
_vehicle . ahrs . set_fly_forward ( false ) ;
} else if ( log_info . update_rate = = 50 ) {
// assume copter for 400Hz
_vehicle . ahrs . set_vehicle_class ( AHRS_VEHICLE_FIXED_WING ) ;
_vehicle . ahrs . set_fly_forward ( true ) ;
}
set_ins_update_rate ( log_info . update_rate ) ;
feenableexcept ( FE_INVALID | FE_OVERFLOW ) ;
@ -635,7 +652,7 @@ void Replay::setup()
@@ -635,7 +652,7 @@ void Replay::setup()
ekf3f = fopen ( " EKF3.dat " , " w " ) ;
ekf4f = fopen ( " EKF4.dat " , " w " ) ;
fprintf ( plotf , " time SIM.Roll SIM.Pitch SIM.Yaw BAR.Alt FLIGHT.Roll FLIGHT.Pitch FLIGHT.Yaw FLIGHT.dN FLIGHT.dE FLIGHT.Alt AHR2.Roll AHR2.Pitch AHR2.Yaw DCM.Roll DCM.Pitch DCM.Yaw EKF.Roll EKF.Pitch EKF.Yaw INAV.dN INAV.dE INAV.Alt EKF.dN EKF.dE EKF.Alt \n " ) ;
fprintf ( plotf , " time SIM.Roll SIM.Pitch SIM.Yaw BAR.Alt FLIGHT.Roll FLIGHT.Pitch FLIGHT.Yaw FLIGHT.dN FLIGHT.dE AHR2.Roll AHR2.Pitch AHR2.Yaw DCM.Roll DCM.Pitch DCM.Yaw EKF.Roll EKF.Pitch EKF.Yaw INAV.dN INAV.dE INAV.Alt EKF.dN EKF.dE EKF.Alt \n " ) ;
fprintf ( plotf2 , " time E1 E2 E3 VN VE VD PN PE PD GX GY GZ WN WE MN ME MD MX MY MZ E1ref E2ref E3ref \n " ) ;
fprintf ( ekf1f , " timestamp TimeMS Roll Pitch Yaw VN VE VD PN PE PD GX GY GZ \n " ) ;
fprintf ( ekf2f , " timestamp TimeMS AX AY AZ VWN VWE MN ME MD MX MY MZ \n " ) ;
@ -680,12 +697,6 @@ void Replay::read_sensors(const char *type)
@@ -680,12 +697,6 @@ void Replay::read_sensors(const char *type)
done_parameters = true ;
set_user_parameters ( ) ;
}
if ( use_imt & & streq ( type , " IMT " ) ) {
have_imt = true ;
}
if ( use_imt & & streq ( type , " IMT2 " ) ) {
have_imt2 = true ;
}
if ( ! done_home_init ) {
if ( streq ( type , " GPS " ) & &
@ -721,26 +732,16 @@ void Replay::read_sensors(const char *type)
@@ -721,26 +732,16 @@ void Replay::read_sensors(const char *type)
}
bool run_ahrs = false ;
if ( streq ( type , " FRAM " ) ) {
if ( ! have_fram ) {
have_fram = true ;
printf ( " Have FRAM framing \n " ) ;
}
run_ahrs = true ;
}
if ( have_imt ) {
if ( ( streq ( type , " IMT " ) & & ! have_imt2 ) | |
( streq ( type , " IMT2 " ) & & have_imt2 ) ) {
run_ahrs = true ;
}
}
// special handling of IMU messages as these trigger an ahrs.update()
if ( ! have_fram & &
! have_imt & &
( ( streq ( type , " IMU " ) & & ! log_info . have_imu2 ) | | ( streq ( type , " IMU2 " ) & & log_info . have_imu2 ) ) ) {
run_ahrs = true ;
if ( log_info . have_imt2 ) {
run_ahrs = streq ( type , " IMT2 " ) ;
_vehicle . ahrs . force_ekf_start ( ) ;
} else if ( log_info . have_imt ) {
run_ahrs = streq ( type , " IMT " ) ;
_vehicle . ahrs . force_ekf_start ( ) ;
} else if ( log_info . have_imu2 ) {
run_ahrs = streq ( type , " IMU2 " ) ;
} else {
run_ahrs = streq ( type , " IMU " ) ;
}
/*
@ -903,7 +904,7 @@ void Replay::loop()
@@ -903,7 +904,7 @@ void Replay::loop()
float temp = degrees ( ekf_euler . z ) ;
if ( temp < 0.0f ) temp = temp + 360.0f ;
fprintf ( plotf , " %.3f %.1f %.1f %.1f %.2f %.1f %.1f %.1f %.2f %.2f %.2f %. 1f %.1f %.1f %.1f %.1f %.1f %.1f %.1f %.1f %.2f %.2f %.2f %.2f %.2f %.2f \n " ,
fprintf ( plotf , " %.3f %.1f %.1f %.1f %.2f %.1f %.1f %.1f %.2f %.2f %.1f %.1f %.1f %.1f %.1f %.1f %.1f %.1f %.1f %.2f %.2f %.2f %.2f %.2f %.2f \n " ,
AP_HAL : : millis ( ) * 0.001f ,
logreader . get_sim_attitude ( ) . x ,
logreader . get_sim_attitude ( ) . y ,
@ -914,7 +915,6 @@ void Replay::loop()
@@ -914,7 +915,6 @@ void Replay::loop()
wrap_180_cd ( logreader . get_attitude ( ) . z * 100 ) * 0.01f ,
logreader . get_inavpos ( ) . x ,
logreader . get_inavpos ( ) . y ,
logreader . get_relalt ( ) ,
logreader . get_ahr2_attitude ( ) . x ,
logreader . get_ahr2_attitude ( ) . y ,
wrap_180_cd ( logreader . get_ahr2_attitude ( ) . z * 100 ) * 0.01f ,