Auto-orienting a flying ship
by Hoshiko · in Torque Game Engine · 11/29/2005 (5:31 pm) · 4 replies
I have a flying vehicle that I want to auto-orient itself; in other words, I want it to always try to point in a certain direction by "auto-thrusting," rather than by locking its orientation to a certain value.
I'm trying to apply a corrective torque in updateForces, but I'm having trouble figuring out how to calculate the necessary torque values. Any suggestions?
I'm trying to apply a corrective torque in updateForces, but I'm having trouble figuring out how to calculate the necessary torque values. Any suggestions?
About the author
#2
12/04/2005 (5:32 pm)
No, I don't. I mean auto-orient, as in making the vehicle point in a certain direction, not just making it always level out. I have looked at the helicopter's auto-level code, but have not been able to adapt it for this purpose.
#3
Find the point or vector you want the ship to point to. Convert it to local object (ship) coordinate space with the appropriate mWorldToObj.mulP or mulV. Normalize the vector. If the y component of the vector is less than zero, set it to zero and normalize the vector again. Now examine the vector's x and z values. Compensate for the z offset by applying torque along x and compensate for the x offset by applying torque along z.
12/04/2005 (6:28 pm)
Just off the top of my head...Find the point or vector you want the ship to point to. Convert it to local object (ship) coordinate space with the appropriate mWorldToObj.mulP or mulV. Normalize the vector. If the y component of the vector is less than zero, set it to zero and normalize the vector again. Now examine the vector's x and z values. Compensate for the z offset by applying torque along x and compensate for the x offset by applying torque along z.
#4
I haven't tried this in a hover vehicle but I checked it with my two-wheel balancing robot and it did seem to work correctly.
For my 200lb balancing bot,
yawGyroForce = 6000;
yawGyroDamper = 250;
worked fine.
12/04/2005 (7:05 pm)
Try this near the end of updateForces, before the gravity calculation. Theta is the desired angle, in radians. Set yawGyroForce and yawGyroDamper to something suitable for your vehicle mass.VectorF desired(cos(theta), sin(theta),0.0);
F32 upCoZ = -mDot(bz,desired);
F32 zAngVel = mDot(bz, mRigid.angVelocity);
mRigid.torque += bz * yawGyroForce * upCoZ - yawGyroDamper * zAngVel * bz;I haven't tried this in a hover vehicle but I checked it with my two-wheel balancing robot and it did seem to work correctly.
For my 200lb balancing bot,
yawGyroForce = 6000;
yawGyroDamper = 250;
worked fine.
Torque 3D Owner Matt Huston
Atomic Banzai Games
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=9263