I have tried using Mahony integration, and it seems to eliminate the drift over the z-axis pretty well, but causes the bindings for x and y to be all over the place. I presume it's because z is converted to radians unlike x and y.
I also thought the deadband would solve this problem, but it doesn't prevent the gyroscope readings from eventually being within the tolerances to cause drift.
Is there another solution either with re-calibrating the z-axis data, or something else that I can use to solve the drift issue?
Here is the x and y rotation around z-axis code:
Code: Select all
x = filters.deadband(filters.delta(yaw),0.01)* mouse_sensitivity
y = filters.deadband(-filters.delta(pitch),0.01)* mouse_sensitivity
z = filters.deadband(math.radians(wiimote[0].ahrs.roll), 0.1)
if wiimote[0].buttons.button_down(WiimoteButtons.A):
mouse.deltaX = math.cos(z)*x - math.sin(z) *y;
mouse.deltaY = math.sin(z)*x + math.cos(z) *y;