Possible to initialize EKF without Mag sensor?

Hello everyone,

I am trying to disable all internal compasses to have an estimated attitude depending on gps yaw for testing purpose. As far as I understand those lines

prevent the estimator from being initialized. Is there anything I am missing? I would like to check how well the system is working, when there is no compass.


@bresch is that possible?

I quickly checked in the code and what you should do is to set EKF2_MAG_TYPE to none such that the mag data is not used. Then, the yaw won’t be initialized in the init function but later, here.
For the rest, you’re right, not having mag data at all will prevent the ekf to initialize correctly.
Also, don’t forget to enable yaw fusion in EKF2_AID_MASK and set the antenna offset in GPS_YAW_OFFSET.

I never tested this before so please tell me if that worked for you.


Thanks a lot.

Your answer might be the solution. I had not seen the option to disable compass via EKF2_MAG_TYPE. Previously I was disabling the individual ones with CAL_MAGX_EN, which prevented ekf from initialization so Ekf::update never got to the point where controlFusionModes is called.

Now I am able to verify the line you mentioned is executed and only Ekf::fuseGpsAntYaw gets called while the compass fusion is not executed anymore. Though the yaw angle in vehicle_global_position and vehicle_local_position do not follow my artificial gps yaw input. I am going to do some more debugging and report back further findings.

I found those lines, which seem to hide the yaw information, I am sending. As the comment says it tries to enable gyro bias learning using stationary phases. I think with gps yaw source we do not need this. Therefore I set EKF_MAG_TYPE=6, so controlMagFusion returns immediately.

This feels more like an hack than an actual solution. @bresch do you have an idea here?

Apart from that, it works now and I will continue testing with real hardware.

That’s correct. We didn’t consider GPS or VIO yaw fusion here; which is a mistake. The variance growth doesn’t need to be artificially constrained if there is some yaw aiding.
I think you did the right thing here to set the mode to 6 (even if this is “unsupported”). We’ll fix that.

I opened an issue to keep track of that: https://github.com/PX4/ecl/issues/800
Please feel free to open a pull request if you feel that you can fix the issue.