Physics Simulation Forum

 

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Sat Jun 16, 2012 3:46 pm 
Offline

Joined: Sat Jun 02, 2012 6:42 pm
Posts: 3
Hi,

I am trying to rotate (not teleport but move) kinematic object by data from phone's gyroscope. I want rotation of this object to be exactly what I have rotation of the phone.
But how I am doing this now: I take quaternion from my gyroscope, take another quaternion from my kinematic object, convert both quaternions to euler angles, and calculate difference of angles between phone and object, and based on this I calculate angular velocity to move my object into the phone position. But It is not working properly, I have few problems when I am doing this, one of these is gimbal lock.

I know in PhysX is something like rotateObjectToQuaternion(), and I can rotate my object (not teleport but move) to specific position based on quaternion.

But I can not find something similar in Bullet. Is there something like that?
If so, can someone tell me what is that function, or how can I accomplish similar result?

Every suggest are appreciate


Top
 Profile  
 
PostPosted: Tue Jun 19, 2012 6:15 pm 
Offline

Joined: Sat Jun 02, 2012 6:42 pm
Posts: 3
After reading this:
http://www.euclideanspace.com/physics/kinematics/angularvelocity/quatDiff1stAttempt.htm
http://www.euclideanspace.com/physics/kinematics/angularvelocity/

I did something like:

Code:
    btQuaternion diffQuater = gyroQuater - boxQuater;
    btQuaternion diffConjQuater;
   
    diffConjQuater.setX(-(diffQuater.x()));
    diffConjQuater.setY(-(diffQuater.y()));
    diffConjQuater.setZ(-(diffQuater.z()));
   
    ////////////////
    //W(t) = 2 * dq(t) /dt * conj(q(t))
   
    btQuaternion velQuater;
   
    velQuater = ((diffQuater * 2) / d_time) * diffConjQuater;


But it is not working as I expect, I mean, there is written, vector part of the result quaternion should be vector of angular velocity, and scalar part should be 0, but my result is not like that.

Quote:
angular velocity vector represented as quaternion with zero scalar part, i.e
W (t ) = (0, W x (t ), W y (t ), W z (t ))


Any ideas?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group