BrianPeek.com

A Compendium of Random Uselessness
in Search

Wiimote AccelState & Controller Orientation

Last post Sat, Jul 7 2007 6:39 AM by Brian Peek. 10 replies.
Page 1 of 1 (11 items)
Sort Posts: Previous Next
  • Tue, May 8 2007 8:42 AM

    Wiimote AccelState & Controller Orientation

    Hi Brian,

    Love the library...giving me endless hours of fun. Smile

    I wondered if you'd have any advice on how I might get my tiny brain around the problem of mapping the Wiimote orientation to the X, Y, Z rotation values I would use in XNA to orient a model mesh so that it precicely followed the orientation of the controller?

    By following a number of abstracts on the math I was quite easily able to deal with Pitch around the X axis but as soon as I start to play with Roll or Yaw, trying to understand the relationship between the axis values makes my ears bleed and no matter what I try, I cant get my model orientation to match the Wiimote's.

    I guess i'm hoping that you've maybe played with this and i'll be able to reverse engineer my understanding from a clipboard paste! Wink

    Either way, many thanks for sharing this with us.

    Al

  • Tue, Jun 12 2007 6:21 AM In reply to

    Re: Wiimote AccelState & Controller Orientation

    Apparently I never replied to this...

    You will only be able to match the Wiimote's orientation on 2 axes with the accelerometers.  To get all 3 axes will require the use of the IR.

    For the 2 axes, it should be a matter of mapping the 0-1.0f values to radians and passing the values to the Matrix.CreateRotationX/Y/Z methods to create your transform matrix.

    Throwing in the IR is a lot trickier and I don't know if I have answer to that off the top of my head...
     

  • Tue, Jun 12 2007 10:51 AM In reply to

    Re: Wiimote AccelState & Controller Orientation

     (jumping in here) 

    > You will only be able to match the Wiimote's orientation on 2 axes with the accelerometers.  To get all 3 axes will require the use of the IR.

     I haven't worked with the remotes yet (they're on order), but why should that be?  AFAIKS, the 3 axes are available, the IR is only used to augment pointing as it wasn't accurate enough with the accelerometers alone.
    --
    gl

  • Tue, Jun 12 2007 11:26 AM In reply to

    Re: Wiimote AccelState & Controller Orientation

    Anonymous:
     I haven't worked with the remotes yet (they're on order), but why should that be?  AFAIKS, the 3 axes are available, the IR is only used to augment pointing as it wasn't accurate enough with the accelerometers alone.

     ... thinking about it, I see what you mean - it can't detect yaw around its own axis, right?

    I believe the accelerometer is in effect a tiny weight suspended on springs, so even at rest you read a downward force (gravity).  So assuming the remote is horizontal, and we're concerned about orientation around the remove's axis, you can detect changes in pitch and roll (the downward force will shift), but not yaw.

    If right, then yes, the IR would allow give you yaw, but only within the detector's field-of-view.

  • Tue, Jun 12 2007 1:04 PM In reply to

    Re: Wiimote AccelState & Controller Orientation

    Exactly correct on all accounts.  You can only get that third axis when the wiimote itself is in motion, otherwise gravity isn't acting upon it.  Hence, the IR solution.
  • Wed, Jul 4 2007 10:46 AM In reply to

    • dimevit
    • Top 50 Contributor
    • Joined on Wed, Jul 4 2007
    • Posts 3

    Re: Wiimote AccelState & Controller Orientation

    Hi Brian I have also sended a mail to you,
     

    from the Wiimote Acc. we can calculate only the pitch and roll, only when the data are between (-1,1), yaw can not be calculated, becouse

    the gravity is going in the Z direction and in that case the Acc at X, and Y is Zero, so no yaw is possible from the acceleration. Also the pitch and roll are

    correct only if the Wiimote is not acceleration (moving) becouse then tha value are bigger than (-1,1). I was also thinking to Integrat over the Wii motion and get the offset and i implemented this,

    but if you move the wiimote and you are rotating the wiimote than the data is not valid any more. So the solution is to use the IR.

    So I measured the Focal lenght, 1320 pixels, but I dont really know how to make the Relatioinship between the 3D Ir and the 2D (projected Ir).

    I need this becouse I want to calculate the motion and the angels of the Wiimote. My Idea is to minimize a objective funciton min(R,t)=pow( P[R,t]Xw - Xp), 2)

        P - Camear Matrix

        R - Rotation Matrix

        t - Translation Vector

       Xw - Ir on the Sensor bar, i build my own sensor bar with Ir on rectangle

       Xp - are the projected Ir on the Image Plane

    So if I minimize this function for every two diff. Images ( that i have during the rotation or the movement of the Wiimote ), I can get the pure Rotation and Translation of the Wiimote, and I allready build an OpenGL program for the Wiimote, there I draw a Virtual Wii.

    But for all this I need the Point correspondencies between the Xw(Ir on the sensor bar) and the Xp(the projected Ir), for this correspondencies I need the projection Matrix.

    Do you have any Idea, how can I or We make this?

    Or my problem is more, how to define the Coordinate System.

    Becouse i have the projection matrix and tha camera matrix

    Camermatrix= ( fx, -tanQ*fx, Hx

                         0,    fy,        Hy,

                        0,     0,         1)
     

     I assume we can take  -tanQ*fx= 0, and I am not so sure if we need Hx and Hy

    Projection matrix ( fx, 0, 0, 0

                                0, fy, 0, 0

                                0, 0, 1, 0 )   where fx=fy= 1320

    The Ir on my sensor bar are at position:

          IR1 (10,10),  IR1(30,10) IR3(30,30) and IR4(10,30)   in cm

     

    So can if the wiimote is on distant 70cm, can I say,    IR1(10,10,70) IR2(30,10,70) IR3(30,30,70) and IR4(10,30,70)

    and this are my World Coord. projected with the above matrix I get 4 2D Ir Data 

    so if I put the wiimote to point to the center of the Sensor bat, at positon (20,20,0)

    can this be my coord. system.

    If yes, then this si my calibration point, where the Rotationmatrix is the Identity matrix

    Can thsi work like this
     
     

    Best wishes,

    Dime Vitanovski

  • Wed, Jul 4 2007 4:52 PM In reply to

    Re: Wiimote AccelState & Controller Orientation

    My first statement:  I suck at math.

    I really don't have any answer that's going to help you on this one.  Any math whizzes out there have any ideas?  Big Smile
     

  • Thu, Jul 5 2007 4:11 AM In reply to

    • dimevit
    • Top 50 Contributor
    • Joined on Wed, Jul 4 2007
    • Posts 3

    Re: Wiimote AccelState & Controller Orientation

    Hi Brian,

     

    thanks you for your answer, but, can you at least tell me, how can I import your Library in a C++ Code

     

    Thanks 

  • Thu, Jul 5 2007 4:21 AM In reply to

    Re: Wiimote AccelState & Controller Orientation

    If you're using managed C++ in Visual Studio, you should be able to just set a reference and use it.

    If you're using native C++, you'd have to create a "COM Callable Wrapper".  No guarantees that will work however...trying to call .NET from native code can definitely be tricky.  I'd suggest looking for a native C++ library.  I know someone is working on a C++ lib based on my code, but it is not yet available.

    COM Callable Wrapper info here:  http://msdn2.microsoft.com/en-us/library/f07c8z1c(vs.80).aspx 

  • Thu, Jul 5 2007 6:25 AM In reply to

    • dimevit
    • Top 50 Contributor
    • Joined on Wed, Jul 4 2007
    • Posts 3

    Re: Wiimote AccelState & Controller Orientation

    Im using Microsoft Visual Studio 2005, and visual C++ 8

    Is it possible to import the Library?
    It is very strange why your IR Result are more accurate then mine result. Do you have any Idea about this`?

    I solved the problem from yesterday, now I know the projective matrix.
    If I solve the second Equation, than we know the real Rotation and Displacement of the Wiimote, and we'll have absolute coordinates

     
    Thanks for the answer,
    Dime

     

  • Sat, Jul 7 2007 6:39 AM In reply to

    Re: Wiimote AccelState & Controller Orientation

    If you're doing native C++, no you can't #import the dll.  You'll need to follow the info above about creating the COM-callable wrapper, or wait find a native C++ lib.

    As for accuracy, I'm not sure...the parsing of IR data was handled using the information on available on the sites linked on the original article...    

Page 1 of 1 (11 items)
Copyright (C) 2008 Brian Peek
Powered by Community Server (Commercial Edition), by Telligent Systems