Get Current Angle Of Revolute Joint
Posted: Sat May 07, 2011 9:41 pm
Greetings! I have been trying my best to not post this question here, but I have spent the better part of a week trying to figure this out. I've looked through most of this forum and some come close to answering it, but not really. Also, please note that I am sort of a beginner at 3D physics stuff, so if possible, a tiny little snippet of sample code would be greatly appreciated!
I notice that in the joint limit, you can specify minimum and maximum angle. I just cannot for the life of me figure out how to retrieve the current angle of the joint. I have tried to calculate this by using the joint error and servo goal. This works somewhat, the the value gets kind of wacky when you initially move the joint. It smooths out after a frame or two.
FYI, this is an example of how I am currently attempting to do this. I have tried many variations on the following...
Yes, I'm sure you will agree that my method is quite "hacky". haha I just know there is a better way and that someone can probably answer this in like 5 seconds. LOL
Many thanks and I really love this engine!!
I notice that in the joint limit, you can specify minimum and maximum angle. I just cannot for the life of me figure out how to retrieve the current angle of the joint. I have tried to calculate this by using the joint error and servo goal. This works somewhat, the the value gets kind of wacky when you initially move the joint. It smooths out after a frame or two.
FYI, this is an example of how I am currently attempting to do this. I have tried many variations on the following...
Code: Select all
float errorMult = 1.0f;
float errorMin = -4.0f;
float errorMax = 4.0f;
myAngle = MathHelper.WrapAngle(revJoint.Motor.Settings.Servo.Goal - MathHelper.Clamp(revJoint.Motor.Error * errorMult, errorMin, errorMax))
Many thanks and I really love this engine!!