I am trying to couple my Bullet Physics world with a Force Feedback Device. The coupling between the device and the physics object uses a position/force loop:
Code: Select all
1 - Read the bullet object's position and speed (using getWorldTransform from the motionState)
2 - Set the device's requested position and speed to match
3 - Read the force and torque needed to apply to the object to move it to the correct position from the device
4 - Apply the force and torque to the bullet object
Now, my problem is I don't know how to apply the force and Torque to the rigid body.
I tried using btRigidBody's applyCentralForce() and applyTorque() methods but the simulation quickly becomes unstable. Looking more closely to the code of these two methods, it seems that each time they are called, they add the force to the m_totalForce and m_totalTorque members which thus grow exponentially.
I tried using clearForces() then just applying my own force and torque (plus gravity) but it doesn't seem to work either as it clears the forces applied by other dynamics in the wolrd (I assume).
I also tried using applycentralImpulse() and applyTorqueImpulse() which don't work either and send my object flying.
Is any of these methods sound? Because if one of them is, I'll have to see why the force and torque I apply are wrong? If not, how can I do what I want to do? Is it even possible?
Thanks in advance to anyone who might help with this.