iNavFlight / inav

INAV: Navigation-enabled flight control software
https://inavflight.github.io
GNU General Public License v3.0
3k stars 1.43k forks source link

Detect and counteract failed compass #1323

Closed giacomo892 closed 8 months ago

giacomo892 commented 7 years ago

I'm doing some experiments to check edge cases of sensor failure.

I'm using a custom NAZE target (F1) running 1.6RC2 on a breadboard using an MPU6050 and HMC5883 as compass.

I want to simulate a compass failure. After some seconds after I unplug the compass from the board the MAG icon became RED and this is ok.

As soon I replug the compass at it's place the icon became blue again (meaning MAG is healthy) but in sensors tab magnetometer values are stuck and those wrong, stuck, values are sent into the IMU giving totally wrong result messing the machine heading computation.

I know this is a very unfortunate fault. So i've tried to unplug only SDA or SCL (leaving mag powered and configured) and I can again encouter the same issue most of the times.

Can we do something more to check the actual health of the mag and re-init it? like heading is changing but mag value are not.

I'm here if needed

digitalentity commented 7 years ago

We have an issue for this check already - https://github.com/iNavFlight/inav/issues/991

giacomo892 commented 7 years ago

If you want, you can close this issue. If the other one is sufficient Btw. am I wrong saying that navigation should work even after a compass failure (at least for emergengy RTH) since heading computed with gyro is quite stable and the quad is facing home during RTH so also GPS heading could be used.

digitalentity commented 7 years ago

@giacomo892 I'd rather keep it open for the time being.

After you acquire true heading you no longer need compass - gyro drift is usually quite small (few degrees a minute). On quads GPS heading can't be used because quad can fly in any direction and GPS heading indicate direction of movement and not the direction where machine is facing.

giacomo892 commented 7 years ago

Ok @digitalentity . I was meaning something a little different. Put we have just detected a compass failure on MC. Excluding it from heading computation we should be able to rotate the MC facing home direction. At this point why cannot be use the GPS heading to navigate home? (assuming the quad is capable of maintaining the heading)

digitalentity commented 7 years ago

@giacomo892 I understand what you are suggesting - that will be a totally different mode of operation for quads. Usually quad direction of flight is disconnected from heading. It can start flying home tail tail first and turn in correct direction in process. That's not possible when using GPS-only heading - we'll have to modify the whole procedure for multirotor flight control to be able to fly like this.

giacomo892 commented 7 years ago

Ok glad you have locked my point :) Thanks for your effort being put in INAV.

digitalentity commented 7 years ago

@giacomo892 I have something that will allow compass-less navigation on the multirotors - this feature is currently in development and testing. Will be a killer feature.

giacomo892 commented 7 years ago

Oh! What a news !!!! I guess I will have to upgrade to F3 :D :D :D :D Keep going!

leanMJ commented 7 years ago

My compass is sometimes not recognition,If the recognitionis always is East。

AirwolfFPV commented 7 years ago

@digitalentity if a multicopter flies at sufficient speed, can the nose heading be determined from gps course and attitude? Provided there is not too much wind.

digitalentity commented 7 years ago

@andre92 we can make assume heading if attitude is not changing too much. I have some interesting code it the works to have a backup system for compass - need to perfect it first.