dlktdr / HeadTracker

This project is built to record the orientation a FPV headset to allow the camera on your RC to follow your head movements.
GNU General Public License v3.0
378 stars 90 forks source link

Pan Drift even after good calibration #92

Open dlktdr opened 2 years ago

dlktdr commented 2 years ago

Let me start out by saying that all Mag sensors are a pain... sorry. If you have ever tried to calibrate a drone with an onboard compass you will know what I mean.

If your mag is calibrated and in a good noise free low magnetic environment you can still see drift in the pan axis.

The issue stems from how it determines the initial orientation and the sensor noise. The mag sensor on the Nano33BLE is noisy. Without a lot of filtering you get this but it responds to a changing field quite quickly.

https://user-images.githubusercontent.com/281145/170827908-9438a9b0-3fdf-4264-a9f4-308b1976d886.mp4

There is a very low amount of mag correction applied on every loop so that this noise doesn't show up on the servos. The result of this is that there is a slow drift until it stabilizes. Since it determines the initial mag alignment on boot, if its not stable on powerup this time to stabilize can be long.

Notes

Solutions

Version 2.2, gyro calibration is done on boot and should help here. Version 2.2, the mag sensor will be filtered by itself alone from the gyr and acc. This allows for quicker response in the fusion algorithm. Seemed to have good results in the tests.

dlktdr commented 2 years ago

See this video on how I do a calibration and some of the issues.

https://www.youtube.com/watch?v=DwtC1GqwQ4U&t=82s

TimothyGold commented 2 years ago

I noticed that when i boot after i put everything on my head and home still until calibration finishing the pan will hold pretty good. This is until i need to rotate to get better reception. Once i do this and re-center drift will start. It does seem to get better again if i am able to make center closer to boot direction. This sometimes is not possible. Is it possible there is something missing in the calculation for re-centering?

dlktdr commented 2 years ago

I'm hoping the changes to be added to 2.2 will address this better, but still needs more testing.

2.13 was just posted that resets the algorithm on every center. It might help.

dlktdr commented 2 years ago

Was checking into it a bit more yesterday and found another issue that might be accounting for a bit of this. There may be an issue with the integration of the gyro signal on fast moves, probably not enough samples to get a great result. If you do a quick movement and stop, the gyro has overshot where is should be, which then due to the filtering slowly drifts back to the proper mag center.

Really wish the IC's were connected with SPI, the I2C bus at the 400khz max is pretty loaded up :(

Velvethsaw commented 2 years ago

I am too experiencing drift after good calibration. Thank you for working on this project!

dlktdr commented 2 years ago

Would you mind testing this version of the software and see if you notice any differences?.

Below is copied from RGC

Drift Issues For everyone experiencing the drifting. Trying some new things that might help. Paul_BB was nice enough to send over a new algorithm that is being tested. This coupled with 2.6x more sensor reads so far I think it's superior.

If you want to try yourselves, https://drive.google.com/file/d/175v...ew?usp=sharing - This hasn't been thoroughly tested. The firmware is included in the above file, under shipped firmware. I wouldn't trust it enough to fly with yet, just an initial test. Code is on Github under the Paul_DCM_AHRS branch

Note: Use the Diagnostics->Reset Defaults option from the GUI before starting. Gyro calibration has been removed so it will take a little while for the algorithm to cancel out the Gyro drift. Like the current firmware please make sure to do a Calibration with headset attached and powered. After power up, hold still for a while, do some motions, then reset the center after it settles. A new center reset was sent as well, but not implemented in the above code. Leave your feedback

Note: (From Paul_BB) The board has its own orientation. Tilt roll pan (pitch roll yaw) of the board are relative to the horizontal component of the local Magnetic field and to the gravity. The centre reset will rotate the orientation of the board to the convenience of the user, when implemented. There is another thing that should be implemented: the initialisation of the board pan at start up. Today the pan is set to zero (local Magnetic North) at start up. So if the board does not face North at start up, pan will need some time to catch up. This will be corrected (if the algorithm is promising).