Wiimote Gyroscope drift around z-axis

Official forum for open source FreePIE discussion and development.
Post Reply
MeteorFalling2
One Eyed Hopeful
Posts: 42
Joined: Thu Dec 08, 2016 10:23 pm

Wiimote Gyroscope drift around z-axis

Post by MeteorFalling2 »

I have been perfecting my script to emulate mouse movements, and everything works really well. However, one of the flaws that I want to address, is that I am using only the x and y movements to emulate the mouse. I would like to rotate the x and y axis according to the z axis rotation. I can get the emulation to be accurate for about 5-10 seconds before the z-axis gyroscopes drift readings become a problem.

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;
Post Reply

Return to “FreePIE”