Calculating Orientation from Raw Values WM+

Dec 6, 2010 at 6:37 AM

Hi,

I'm an undergraduate student working on a signals project involving the M+ gyroscope sensor. I have a question regarding calculating the orientation from raw values.

When you calculated y, p, r values from the Raw values of the M+ accessed by wiimotelib, you multiply the values by 0.0155 to convert to deg/s. May I know where you get that number from? In the wiibrew page, they've mentioned a raw value of 8063 corresponds to 595 deg/s therefore to convert to deg/s we need to multiply by 595/8063  (=0.074) But when I do that, I'm not able to scale it between 0 and 360 degrees. Yours seems more accurate. So, could you explain how you arrived at degree values from the raw values?

Sorry I didn't know any other way to contact you ; I saw your comment in BrianPeek's blog.

Thanks!

Imelza

Coordinator
Dec 6, 2010 at 1:02 PM
Edited Dec 6, 2010 at 1:07 PM

Imelza,

Hmmmm.  I thought I sent you the answer, but I was wrong.  Let me think about it some more.

Jeremy

 

 

Coordinator
Dec 6, 2010 at 3:48 PM

I believe that value was used to convert from degrees per second to degrees per update time (15 milliseconds).  

Jeremy Sneeden

Dec 6, 2010 at 5:17 PM

Hi, I got your reply, thanks! Now what's that G.z you use in the formula? 

Angle.Z = .98f * (Angle.Z + (G.Z * .015f)) + .02f * A.Z;

I understand Angle.z is the integration sum and A.z is the new turn rate right? Doing G.z*updatetime makes G.z look like some angle...

You see, I've been trying to make sense of the raw values from WM+ using this method

  1. Calibrate the Motionplus (i.e. Find the raw value that corresponds to zero; I do this by holding it stationary for a point of time)

  2. For every subsequent raw value read, I subtract the zero value from it to get the "relative" raw value.

  3. Then, I scale this value using http://wiibrew.org/wiki/Wiimote/Extension_Controllers (checking for yaw_fast, pitch_fast etc.), and multiply by 0.33 if its in fast mode and 0.072 if its in  slow mode

  4. Finally I sum up all these values over time (discrete integration) to get the angle of the wiimote wrt initial orientation.

    To calculate this relative to world coordinates,  I add an initial orientation value I get from an electronic compass.

    The problem is my values just won't scale, and even when my wiimote is stationary, my y,p,r values add up to over 360-400 degrees eventually. I have no idea where this extra noise is coming from; I calculate my zero value by checking for 2 consecutive identical raw values initially. 

    Do you know where I might be going wrong?

    Thanks, and I'm sorry for the bother!   

 

 

 

Coordinator
Dec 6, 2010 at 7:02 PM
Edited Dec 6, 2010 at 7:04 PM
  • Calibrate the Motionplus (i.e. Find the raw value that corresponds to zero; I do this by holding it stationary for a point of time) - Exactly what I do.  It is zeroed by pressing the button to start a swing.

  • For every subsequent raw value read, I subtract the zero value from it to get the "relative" raw value. - Exactly what I do.

  • Then, I scale this value using http://wiibrew.org/wiki/Wiimote/Extension_Controllers (checking for yaw_fast, pitch_fast etc.), and multiply by 0.33 if its in fast mode and 0.072 if its in  slow mode - I would check on this.  I have .25 and .05 as my values for multiplication (actually I divide by 4 and 20).  

  • Finally I sum up all these values over time (discrete integration) to get the angle of the wiimote wrt initial orientation. This is what I do, but I only take 98% of the value.  This is leftover from experimenting with various methods of combating jitter. 

    To calculate this relative to world coordinates,  I add an initial orientation value I get from an electronic compass.

    I do this to create an orientation matrix for my disc: 
    return Quaternion.CreateFromYawPitchRoll(MathHelper.ToRadians(Angle.Z * -1), MathHelper.ToRadians(Angle.X), MathHelper.ToRadians(Angle.Y));  This is bad and needs some checking to ensure you are multiplying the right axis by -1.  It works fine if the wiimote was faceup when initialized.

    A.Z is currently set to 0, and as far as I can see is never changed.  I was experimenting with various methods for reducing jitter, and I kept the formulas there to facilitate experimentation.  The A.Z (and the accompanying percentage) can be used to smooth the jitter by setting it to the previous value of the Angle.  Then you can change the percentages to adjust for how much you "trust" the data from the sensor.  I know from experience that getting this to work can be extremely frustrating.  When it does finally work (or somewhat work in my case), it is pretty cool.

    Jeremy