Correct IMU gyro input to be based on sample loop time rather than actual delta time
commit50ce338390f0dd5795b567da23967aa0804207b2
authorBruce Luckcuck <github@etracer.net>
Fri, 26 Jul 2019 20:32:03 +0000 (26 16:32 -0400)
committerBruce Luckcuck <github@etracer.net>
Fri, 26 Jul 2019 20:32:03 +0000 (26 16:32 -0400)
tree36e75fbb9dd8a242dbdaa36e37bfeb744eaf668a
parent0f230c42a194e5230653d34f24629c748fcd421d
Correct IMU gyro input to be based on sample loop time rather than actual delta time
The current calculation accumulates gyro data between IMU updates based on the actual time delta betwwn samples. The problem with this is that loop time jitter or delays will decrease the accuracy of the gyro rotational input into the attitude calculation. The sensor samples based on a hardware driven clock that matches the `gyro.targetLooptime`. The sensor captures samples at these intervals regardless of when we read them so the calculation should be based on the duration between samples rather then the duration between processing loops.

Will improve the accuracy of the IMU attitude estimate - particularly in cases of higher CPU load and increased looptime jitter. Bench testing shows reduced drift. Also flight tested and behaved as expected.
src/main/sensors/gyro.c