diff --git a/sw/airborne/subsystems/ahrs/ahrs_int_cmpl.c b/sw/airborne/subsystems/ahrs/ahrs_int_cmpl.c index bcf3c695d2..a3ee9a7abc 100644 --- a/sw/airborne/subsystems/ahrs/ahrs_int_cmpl.c +++ b/sw/airborne/subsystems/ahrs/ahrs_int_cmpl.c @@ -83,13 +83,16 @@ void ahrs_init(void) { ahrs.status = AHRS_UNINIT; - // FIXME: make ltp_to_imu and ltp_to_body coherent + /* set ltp_to_body to zero */ INT_EULERS_ZERO(ahrs.ltp_to_body_euler); - INT_EULERS_ZERO(ahrs.ltp_to_imu_euler); INT32_QUAT_ZERO(ahrs.ltp_to_body_quat); - INT32_QUAT_ZERO(ahrs.ltp_to_imu_quat); INT32_RMAT_ZERO(ahrs.ltp_to_body_rmat); INT_RATES_ZERO(ahrs.body_rate); + + /* set ltp_to_imu so that body is zero */ + QUAT_COPY(ahrs.ltp_to_imu_quat, imu.body_to_imu_quat); + RMAT_COPY(ahrs.ltp_to_imu_rmat, imu.body_to_imu_rmat); + INT32_EULERS_OF_RMAT(ahrs.ltp_to_imu_euler, ahrs.ltp_to_imu_rmat); INT_RATES_ZERO(ahrs.imu_rate); INT_RATES_ZERO(ahrs_impl.gyro_bias); @@ -100,7 +103,6 @@ void ahrs_init(void) { void ahrs_align(void) { - /* Compute an initial orientation using euler angles */ ahrs_int_get_euler_from_accel_mag(&ahrs.ltp_to_imu_euler, &ahrs_aligner.lp_accel, &ahrs_aligner.lp_mag); /* Convert initial orientation in quaternion and rotation matrice representations. */ diff --git a/sw/airborne/subsystems/ahrs/ahrs_int_cmpl_euler.c b/sw/airborne/subsystems/ahrs/ahrs_int_cmpl_euler.c index 222673709e..2ffca07eca 100644 --- a/sw/airborne/subsystems/ahrs/ahrs_int_cmpl_euler.c +++ b/sw/airborne/subsystems/ahrs/ahrs_int_cmpl_euler.c @@ -48,12 +48,19 @@ static inline void compute_body_orientation(void); void ahrs_init(void) { ahrs.status = AHRS_UNINIT; + + /* set ltp_to_body to zero */ INT_EULERS_ZERO(ahrs.ltp_to_body_euler); - INT_EULERS_ZERO(ahrs.ltp_to_imu_euler); INT32_QUAT_ZERO(ahrs.ltp_to_body_quat); - INT32_QUAT_ZERO(ahrs.ltp_to_imu_quat); + INT32_RMAT_ZERO(ahrs.ltp_to_body_rmat); INT_RATES_ZERO(ahrs.body_rate); + + /* set ltp_to_imu so that body is zero */ + QUAT_COPY(ahrs.ltp_to_imu_quat, imu.body_to_imu_quat); + RMAT_COPY(ahrs.ltp_to_imu_rmat, imu.body_to_imu_rmat); + INT32_EULERS_OF_RMAT(ahrs.ltp_to_imu_euler, ahrs.ltp_to_imu_rmat); INT_RATES_ZERO(ahrs.imu_rate); + INT_RATES_ZERO(ahrs_impl.gyro_bias); ahrs_impl.reinj_1 = FACE_REINJ_1;