C# GYROSCOPE

All questions related to the configuration tool and groundstation

Moderator: lukasz

C# GYROSCOPE

Postby originaltomato » Sun Feb 14, 2010 8:49 pm

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
originaltomato
 
Posts: 6
Joined: Sun Feb 14, 2010 8:42 pm

Re: C# GYROSCOPE

Postby originaltomato » Mon Feb 15, 2010 3:53 pm

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.
originaltomato
 
Posts: 6
Joined: Sun Feb 14, 2010 8:42 pm

Re: C# GYROSCOPE

Postby Tom » Mon Feb 15, 2010 5:58 pm

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
User avatar
Tom
Site Admin
 
Posts: 1016
Joined: Fri Nov 13, 2009 6:27 pm
Location: Belgium

Re: C# GYROSCOPE

Postby originaltomato » Wed Feb 17, 2010 12:03 pm

hey, just so your post, will check it out now.

thanks.
originaltomato
 
Posts: 6
Joined: Sun Feb 14, 2010 8:42 pm

Re: C# GYROSCOPE

Postby originaltomato » Wed Feb 17, 2010 12:41 pm

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.
originaltomato
 
Posts: 6
Joined: Sun Feb 14, 2010 8:42 pm

Re: C# GYROSCOPE

Postby originaltomato » Wed Feb 17, 2010 1:09 pm

pps whats the order in the quaternion? wxyz or xyzw ?
originaltomato
 
Posts: 6
Joined: Sun Feb 14, 2010 8:42 pm

Re: C# GYROSCOPE

Postby Tom » Wed Feb 17, 2010 1:58 pm

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 :-)
User avatar
Tom
Site Admin
 
Posts: 1016
Joined: Fri Nov 13, 2009 6:27 pm
Location: Belgium

Re: C# GYROSCOPE

Postby originaltomato » Wed Feb 17, 2010 2:11 pm

and some answer for my question before the last one? :)
originaltomato
 
Posts: 6
Joined: Sun Feb 14, 2010 8:42 pm

Re: C# GYROSCOPE

Postby Tom » Wed Feb 17, 2010 3:06 pm

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.
User avatar
Tom
Site Admin
 
Posts: 1016
Joined: Fri Nov 13, 2009 6:27 pm
Location: Belgium


Return to Software

Who is online

Users browsing this forum: No registered users and 7 guests

cron