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
Steering objects by gyroscope?
-
- Posts: 3
- Joined: Sat Jun 02, 2012 6:42 pm
Re: Steering objects by gyroscope?
After reading this:
http://www.euclideanspace.com/physics/k ... ttempt.htm
http://www.euclideanspace.com/physics/k ... rvelocity/
I did something like:
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.
http://www.euclideanspace.com/physics/k ... ttempt.htm
http://www.euclideanspace.com/physics/k ... rvelocity/
I did something like:
Code: Select all
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;
Any ideas?angular velocity vector represented as quaternion with zero scalar part, i.e
W (t ) = (0, W x (t ), W y (t ), W z (t ))