-
Notifications
You must be signed in to change notification settings - Fork 13.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[EKF2] Tilt estimate improvements #24247
base: main
Are you sure you want to change the base?
Conversation
This prevent rapid switching in presence of noise and the innovation filter is good at rejecting spikes
Gravity fusion uses the bias corrected accelerometer data to correct the tilt estimate. We should not continue to estimate the accel bias when this is active as it creates an unwanted feedback loop.
@@ -54,8 +54,9 @@ void Ekf::controlGravityFusion(const imuSample &imu) | |||
|
|||
const float upper_accel_limit = CONSTANTS_ONE_G * 1.1f; | |||
const float lower_accel_limit = CONSTANTS_ONE_G * 0.9f; | |||
const bool accel_lpf_norm_good = (_accel_magnitude_filt > lower_accel_limit) | |||
&& (_accel_magnitude_filt < upper_accel_limit); | |||
const float accel_lpf_norm_sq = _accel_lpf.getState().norm_squared(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_accel_lpf
is only being updated during init, but I was thinking we should move it regardless.
PX4-Autopilot/src/modules/ekf2/EKF/ekf.cpp
Lines 180 to 198 in beb7e7d
bool Ekf::initialiseFilter() | |
{ | |
// Filter accel for tilt initialization | |
const imuSample &imu_init = _imu_buffer.get_newest(); | |
// protect against zero data | |
if (imu_init.delta_vel_dt < 1e-4f || imu_init.delta_ang_dt < 1e-4f) { | |
return false; | |
} | |
if (_is_first_imu_sample) { | |
_accel_lpf.reset(imu_init.delta_vel / imu_init.delta_vel_dt); | |
_gyro_lpf.reset(imu_init.delta_ang / imu_init.delta_ang_dt); | |
_is_first_imu_sample = false; | |
} else { | |
_accel_lpf.update(imu_init.delta_vel / imu_init.delta_vel_dt); | |
_gyro_lpf.update(imu_init.delta_ang / imu_init.delta_ang_dt); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was moving it here, but got a little sidetracked. #24046
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ouch, I didn't realize that; thanks
Solved Problem
Constant small accelerations during gravity fusion creates a small tilt error. As a consequence, the accel bias gets incorrectly estimated and the gravity fusion (using this bias estimate) takes more time to correct back the error.
Solution
Stop accel bias estimation while gravity fusion is active.
Additionally:
Test coverage
EKF replay, unit tests, SITL tests
Before: rapid flag switching
![image](https://private-user-images.githubusercontent.com/14822839/406082529-573f0858-ce27-49a4-a5ac-a6b606dad717.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkwOTAzMjUsIm5iZiI6MTczOTA5MDAyNSwicGF0aCI6Ii8xNDgyMjgzOS80MDYwODI1MjktNTczZjA4NTgtY2UyNy00OWE0LWE1YWMtYTZiNjA2ZGFkNzE3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA5VDA4MzM0NVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWFhNmU4NmUwZTJjMmJlYWZlZTVhNTEyNzMyZTkyOTUzN2JhYzI0N2Y5MjA1ZWI5ZjNjMmNiYmU4MWQ1MjBkZmYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.4asKmoSu6jAs6rRZpK-PNG7mdUMnDQY7RYn-QhO780I)
After: incorrect acceleration are rejected by he innovation filter and not the control flag
![Screenshot from 2025-01-23 15-47-29](https://private-user-images.githubusercontent.com/14822839/406081892-76218d9f-6a9a-414d-b213-5e3d0480bb89.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkwOTAzMjUsIm5iZiI6MTczOTA5MDAyNSwicGF0aCI6Ii8xNDgyMjgzOS80MDYwODE4OTItNzYyMThkOWYtNmE5YS00MTRkLWIyMTMtNWUzZDA0ODBiYjg5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA5VDA4MzM0NVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTcwMzE1MjJhMzk4YTk0Njc0OTlkM2I1Y2FiNzk1M2VlZmVlNmRiODE4NmY5MzgzMmVmOTJlNmY5OGY2ZmU3MzYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.DGdZYGLMUuHUN47DKZiLJxmDLoWMWbgGihXo9Z9JDEA)