EKF2 not intializing on fresh hardware, gets fixed after sensor calibration parameter factory reset

Background

I’ve noticed that with certain sensor calibration parameters, the EKF2 just fails to initialize & provide attitude estimates.

It would either:

  1. Not initialize at all, and there would be no local pose data (velocity, position, attitude)
  2. Initialize, but have erratic attitude and pose data (diverging position, completely wrong attitude)

Example log: https://logs.px4.io/plot_app?log=003e2dc9-7795-4c9a-8fc2-803f35b709c1

Sensor Calibration Parameters Reset

This issue disappears indeed when the sensor calibration data is reset (as reported in a post linked below as well).

When I did the reset, it also then allowed EKF2 to initialize correctly, and when I do the diff of parameters, it comes out like this (Left is before reset, Right is after reset):

File comparison  : before_reset.txt | after_reset.txt
================================================================================
--------------------------------------------------------------------------------
Component 1-1:
--------------------------------------------------------------------------------
CAL_ACC0_XOFF    : -0.314           | 0.00975        
CAL_ACC0_XSCALE  : 1.06             | 1              
CAL_ACC0_YOFF    : -0.614           | -0.00372       
CAL_ACC0_YSCALE  : 1.01             | 1              
CAL_ACC0_ZOFF    : 2.63             | -0.018         
CAL_ACC0_ZSCALE  : 1.47             | 1              
CAL_ACC1_XOFF    : -0.0503          | -0.000126      
CAL_ACC1_XSCALE  : 1.08             | 1              
CAL_ACC1_YOFF    : -0.672           | 0.00871        
CAL_ACC1_YSCALE  : 1.03             | 1              
CAL_ACC1_ZOFF    : 2.36             | -0.121         
CAL_ACC1_ZSCALE  : 1.51             | 1              
CAL_GYRO0_XOFF   : 0                | -0.00197       
CAL_GYRO0_YOFF   : 0                | -0.00372       
CAL_GYRO0_ZOFF   : 0                | -0.00245       
CAL_GYRO1_XOFF   : 0.00332          | 0.00269        
CAL_GYRO1_ZOFF   : 0.0232           | 0.0157         
CAL_GYRO2_ID     : 1310988          | 0              
CAL_GYRO2_PRIO   : 50               > X              
CAL_GYRO2_ROT    : -1               > X              
CAL_GYRO2_XOFF   : 0.000103         > X              
CAL_GYRO2_YOFF   : 0.000054         > X              
CAL_GYRO2_ZOFF   : 0.000063         > X              
CAL_MAG0_ID      : 0                | 396321         
CAL_MAG0_PRIO    : -1               | 50             
CAL_MAG0_XOFF    : 0                | 0.028          
CAL_MAG0_YOFF    : 0                | -0.0573        
CAL_MAG0_ZOFF    : 0                | -0.0387        
CAL_MAG_COMP_TYP : X                < 0              
CAL_MAG_SIDES    : X                < 63             
COM_FLIGHT_UUID  : 8                | 9              
LND_FLIGHT_T_LO  : 154845050        | 174930794      
SENS_BOARD_X_OFF : 0                | -1.18          
SENS_BOARD_Y_OFF : 0                | -0.124         
SENS_MAG_AUTOCAL : X                < 1              
SENS_MAG_AUTOROT : X                < 1              
SENS_MAG_SIDES   : X                < 63             
SYS_HAS_MAG      : 0                | 1              
================================================================================
38 parameters differ

One of the big differences are definitely the accelerometer offset values, which seemed to have messed up the EKF2.

Question

I am wondering how tolerant EKF2 is to such bad calibration data (since even before doing the reset, it seemed like sensor_accel data contained sane output, around 9.8 m/s^2, as in the log linked above), regarding it’s initialization & pose estimation.

Would it make sense to have some kind of alert mechanism to notify user in case the calibration seems off, if that’s detectable? @bresch

How did you end up with such a bad accel calibration? The z scale is 1.47, which is insanely high.

Maybe we should make the accel calibration fail if the scale is above a certain threshold (maybe > 1.1, that’s already quite large).

2 Likes