MarvelMind + Px4 Position Corruption by EKF

Hello,
I am using Px4 fmu v2 with sw version 1.13. I have also Marvelmind system successfully integrated with Px4 and read as GPS with 3D fix (8 satellites). Using NMEA protocol and baud rate 115200. Normally the Marvelmind is about 2cm accurate and sent as a GPS data then will be accurate in xyz (check blue line in the log file below). From Px4 SW point of view, I can see that it will be fused in the EKF, so I had a workaround. Is to increase the noise of the Barometer and decrease the one for the GPS with the following parameters (but I have issues listed after that)

GPS_1_PROTOCOL = 6 (NMEA)
EKF2_ACC_NOISE = 1
EKF2_AID_MASK = 1 (GPS)
EKF2_BARO_NOISE = 15
EKF2_BARO_GATE = 5
EKF2_BETA_NOISE = 1
EKF2_GPS_P_NOISE = 0.08
EKF2_GPS_V_NOISE = 0.1
EKF2_GPS_P_GATE = 4
EKF2_HGT_MODE = (GPS)
EKF2_MAG_TYPE = either 3axis or magnetic heading (compass is calibrated)
COM_ARM_MAG_ANG = -1
EKF2_GPS_CHECK = 0 (no checks)
MPC_POS_MODE = 0 (Simple Positioning Method)

as in the log file I have the following issues
1- x is ok but y and z are not (while they are very accurate from Marvel mind and I do not need EKF at all for all of them) → how to disable completely to eliminate these issues of wrong Estimation even to comment it in the code but where (red position estimate in the log is very annoying because they will have a bad behavior in Position control for sure) → also the test done at same attitude (manually holding the quad after arm)
2- Yaw is not correct at all with EKF2_MAG_TYPE is 3axis or magnetic heading → same yaw angle and fixed while doing the test manually holding so what to do ?

Log file
https://review.px4.io/plot_app?log=bd0c16be-1025-4b76-9f77-775b19fb5118

To me it mainly looks like an orientation issue; when stopping, the EKF feels an acceleration instead of a deceleration from the IMU, meaning that the body frame isn’t aligned properly. Are you sure about the correct rotation of all the components? Can you share a picture of the setup?

It looks like you only have an internal magnetometer, they are usually quite bad and we recommend to use an external one usually. Marbvemind also recommends using an external one (https://marvelmind.com/pics/marvelmind_px4_integration.pdf) and use heading fusion as this is more robust than 3D mag fusion when the field is disturbed

Hello bresch,
Thank you for your reply.
1- For the setup, please find it here

If it is OK, what do you suggest to do, is there a way to disable this compensation from the IMU as I do really want to match the Marvelmind Position exactly exactly without any estimation because it adds errors even from the code if there is no parameter option? and this is related the second part ?

This is the picture I have, but for your info also, I aligned the direction of PX4 with the North of the Marvel Mind, I mean movements in x and y are pure and match the movements of marvelmind dashboard

Other picture (but without px4 unfortunately, but imagine its position as the same as picture before)

2- Ah, I got the info from you now that EKF_MAG_TYPE = Magnetic Heading means external Magnetometer. OK it is clear now, Can I use the Compass used in the GPS module without using the GPS data itself (only to connect the I2C port) ?

Fusing the IMU ins’t the issue here, the estimate is only bad because something isn’t properly setup yet; you need a proper velocity and heading estimate to fly the drone autonomously, you can’t just use raw local position data from the Marvelmind anyway. The issue probably comes from the magnetometer.

It doesn’t mean “external magnetometer” but it’s computing the heading using mag data and fuses it as an angle in the EKF. 3D fusion means that the EKF fuses the 3D magnetic data directly. 3D fusion is more “exact” but the mag heading fusion is more robust. But still, using an external magnetometer is required as the one inside the pixhawk is often really unreliable due to all the components around.

Yes, you can do that; just connect the power and the I2C bus and you should get the mag data

OK Thank you bresch,
I will connect the external magnetometer and do the test again and come back to you. If you recommend anything else just let me know. I have a question, what If I sent these data as an external vision system through MAVROS, will be there also an estimated position ? If no, do you recommend to do it to get the exact data from the marvel mind ?

Hello, I added the magnetometer and changed the pixhawk, calibrated, got the good, calibrated again and had the bad.

I have these 2 parameters from the log Untitled Diff - Diff Checker, the left is the good and refers to pic1, the green is the bad and refer to the pic2. I am using marvelmind indoor as a GPS, the only difference is the calibration parameters as I did it twice. Can you have a look and tell me why is that and how to do the calibration again to reach Pic 1


Log files
Good
https://review.px4.io/plot_app?log=c5b12148--9014-42bcd95cdbed

Bad
https://review.px4.io/plot_app?log=199fde5b-c3db-4e5d-97c4-6967f0e846b7