-
Notifications
You must be signed in to change notification settings - Fork 510
EKF: use low pass filtered mag measurements for heading initialization #524
Conversation
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.
This is not going to work. mag_init is not updated after Ekf::initialiseFilter() has completed and is taken from _mag_filt_state. I would move the calculation of _mag_filt_state to EstimatorInterface::setMagData and use that instead.
mag_init in this case is what is passed into the function so if I don't miss something it is indeed updated In So this PR would solve the first issue mentioned here that we should use the low pass filtered mag measurements for heading initialization, but not the fact that as soon as we get GPS lock we again reinitialize the heading without a low pass filter on the mag measurements. |
I could do that after this is merged. However, before I start I just want to hear your opinion on the following: Say we constantly run a low pass filter on the mag data and use that every time we reset the heading based on the magnetometer. Currently that would mean that we first initialize the heading at boot up, then when we get GPS lock we again reset the heading, still on the ground so all fine. However, then we take off, say with automatic switching of 3D fusion active. We reach e.g. 30 meter altitude and stay there for some time, then we start rotating in yaw, now since the mag bias is declared observable we activate 3D fusion for the first time and hence reset the heading. Since we are rotating there will be a lag between the mag measurements and the true heading so we might end up with a worse heading estimate than before. |
OK, I think I now understand the problem and what you are proposing. I checked out this PR and following the code through it looks like there are no adverse effects and it solves the issue of noise affecting the initial alignment so I will approve and merge it once there is a test log. With respect to yawing and lag due to filtering, because we run the fusion on a delayed time horizon, by filtering the data going onto the buffer and using a filter that has a group delay equivalent to the buffer length, the effects of filter lag will be cancelled. |
I don't have access to a system running standard PX4 at the moment, Is a sitl log enough?
True, nice! |
SITL will be OK |
Here is a sitl logfile with current master PX4 and this PR |
in initialiseFilter() we low pass filter the measurements from the magnetometer, however when initializing the heading we took the last value from the mag instead of the filtered values. At least in SITL this sometimes results in up to 5 degrees heading error at bootup