Page 1 of 1

C# GYROSCOPE

PostPosted: Sun Feb 14, 2010 8:49 pm
by originaltomato
Hello,

I'm using c# and WPF 3d to control an object on screen with a 3-axis gyro. Something very similar to the video on the main page. I'm trying to use Quaternions but I simply don't get it. I get the value of angle change from angular velocitty * time. I understand that Quaternions should allow me to aggregate the rotation. But i simply can't get it. If i do newQuaternion=oldQuaternion*newRotationQuaternion I get proper rotation only on single axis movement. I would be happy with the most simple of programs if you could help. I might use a complementary filter with an accelerometer i have in the device but first I need to get proper yaw, pitch, roll from my gyro.

Thanks,
Vladimir

Re: C# GYROSCOPE

PostPosted: Mon Feb 15, 2010 3:53 pm
by originaltomato
I am begging, help.

I can't seem to understand. How do I transfer a local rotation into global rotation if i have a Quaternion from the last rotation?

I'm so stuck and my deadline is getting closer.

Re: C# GYROSCOPE

PostPosted: Mon Feb 15, 2010 5:58 pm
by Tom
Hello Vladimir,

I don't really understand where it's going wrong for you...
Here you can find the quaternion code I use:
http://code.google.com/p/gluonpilot/sou ... aternion.c

Maybe something differs from your implementation?

Tom

Re: C# GYROSCOPE

PostPosted: Wed Feb 17, 2010 12:03 pm
by originaltomato
hey, just so your post, will check it out now.

thanks.

Re: C# GYROSCOPE

PostPosted: Wed Feb 17, 2010 12:41 pm
by originaltomato
Hi,

Ok, so the function quaternion_update_with_rates is what i'm looking for. I think :). What I don't understand is what is dt in the function. Are you calling this function every 20ms (every received packet) and updating your rotation for every packet of the gyro? Why do you have Initialize for a quartenion? When do you call Initialize ?

ps thanks for responding, love your project and dedication.

Re: C# GYROSCOPE

PostPosted: Wed Feb 17, 2010 1:09 pm
by originaltomato
pps whats the order in the quaternion? wxyz or xyzw ?

Re: C# GYROSCOPE

PostPosted: Wed Feb 17, 2010 1:58 pm
by Tom
I don't really know. Compare the code I would suggest... I numbered them from 0 to 3 to make sure there is no confusion :-)

Re: C# GYROSCOPE

PostPosted: Wed Feb 17, 2010 2:11 pm
by originaltomato
and some answer for my question before the last one? :)

Re: C# GYROSCOPE

PostPosted: Wed Feb 17, 2010 3:06 pm
by Tom
dt is the time in seconds since the last call (used to integrate the rotation rates). Because I do this at 100Hz this value is 0.01 (yes it seems as if I forgot the documentation of this function)

Initiliazation calculates q0, q1, q2 and q3 for a given pitch, roll and yaw angle.