[solved] Wii hacking maths headache

August 8th, 2016

Right then….. I’m messing about with wiimotes and i’ve come unstuck on the following problem. The wiimote has 3 accelerometers in it, and when it’s stationary, you can use those three accelerometers to deduce orientation. The values given out by the accelerometers are effectively sin(theta), as g is taken to be one. What i’m trying to do here, is measure the roll of the wiimote (ie, the amount of gravity ‘seen’ by the x accelerometer). When the wiimote is flat, it’s fine, you just directly take the x accelerometer value, but as you pitch upwards, the roll becomes obscured by the y component. Take the following diagram:
Image
The value the x accelerometer will read is 0.5, but what it should read is sqrt(2)/2 as it is tilted at 45 degrees (sin(45) = sqrt(2)/2). I came up with X = x*(1-y) + y*(1-x) but it’s just plain wrong. Does anybody have any elequent mathematic insights it calibrating x based on y?
I know it’s an ultra simple mathematic relation but I just can’t find it!
I’m only bothered about getting the right x value, and can’t use z as when it is fully operational, most of the movement will be in the z axis. Many many thanks

Answer #1
let me check if i got ur question correctly..
u want the value of “X” which represents “roll” to be 0.5 when the remote is making an angle of 45* with x-axis
and you want x(notice the lower case) to be in terms of y??
Answer #2
x is the value read directly off the x accelerometer
X is the value that would be read if the wiimote were flat, and is the value we want to obtain
Y always = y and is the value read from the y accelerometer When the wiimote is flat (ie y=0) X=x. As soon as you pitch up, lifting y of the floor X=/=x.
At y=45* and X=45*, x(the value read on the accelerometer) will only read 30* as the wiimote is pitched upwards by 45*.
To answers your question directly, If X is making a 45 degree angle with the x axis, the equation should make it so that it is sqrt 2/2 regardless of y. I’ll want the value of X to be sqrt(2)/2 if x=0.5 and y=sqrt(2)/2
I’m wanting to find X in terms of x and y
Thanks for taking a look at this
EDIT: This might make it a bit easier. Here are a few values which should make it a bit easier to visualise.
sqrt(2)/2 ~= 0.7
y___x____X
0—-0——0
0—-0.7—-0.7
0—-1——1
0.7–0.5—-0.7
0.7–0.7—-1
1—-n——UNDEFINED(becomes impossible if x is orthogonal to x-axis but not so much of a problem)
Answer #3
At y=45* and X=45*, x(the value read on the accelerometer) will only read 30* as the wiimote is pitched upwards by 45*.
i dont understand what you mean in that statement
as far as i can understand..
x=> angle made by the remote wrt +X Axis
y=> angle made by the remote wrt +Y Axis
X=> f(x,y)
confirm..
Answer #4
sorry, been away for a week..
x = cos(angle made with x axis)
y = cos(angle made with y axis)
X=f(x,y)
Answer #5
i dont think X will be just function of x and y axis
we need to have the component of the z axis too
Answer #6
i dont think X will be just function of x and y axis
we need to have the component of the z axis too

I’m not sure we do. As we’re only looking to get X in terms of y and x, and there is no rotation in the z axis. if x = sin(phi) z will effectively = cos(phi) which doesn’t give us anything new for the variable scope we’re looking at.
Answer #7
now i can understand the other variables but how do u define ‘X’?? i cant interpret it mathematically using sample values
Answer #8
i think I have it….
X=x/cos(phi)
Answer #9
i think I have it....
X=x/cos(phi)

but its not “dependent” on ‘y’ and the sample values u gave are not coinciding with this..
Answer #10
i think I have it....
X=x/cos(phi)

but its not "dependent" on 'y' and the sample values u gave are not coinciding with this..

Sorry, didn’t make that very clear..
I’m 99% sure that phi=phi2, but for arguments sake, lets invent phi2 and Lets call the angle phi2 the one opposite to phi (ie, when wiimote is flat, phi 2 =0)
By this, y=sin(phi2) as when flat, y=0 and phi2=0 so sin(phi2)=0.
We need to use this value of y to manipulate x to get X.
y=sin(phi2) If we do X= x/y ie cos(theta) = x/cos(phi2).
When y=0*, cos(phi2)=1, so no change to anything. X=x/1
When y=45* and x=45*
X= 0.5/(sqrt(2)/2) = sqrt(2)/2
problem solved.
Here is an excel sheet and a graph of the input space:
x=sin(theta)
y=cos(phi2)
Image

 

| Sitemap |