MaxDZ8 wrote:
[*]I'm afraid I don't understand the whole point. I'll just fetch it to the corresponding MotionState. If force is used, I'll have and handle to the object.
You're right, I was not very clear

Well in my mind, it's two different things:
- either you use kinematic mode and set the position in the MotionState, but in this case the object is not simulated by bullet physics (which is not what you want, as far as I understood)
- or you use your object as a dynamic object, but you have to re-inject extra-forces in the bullet engine whenever you want to control the position/orientation more precisely, which is what is doing the PID controller
MaxDZ8 wrote:
[*]I'll write it again. If I google for "PID controller" or "PID controller for physics simulation" all I get is math and stuff related to electronics. Mapping those concepts to what I need appears nontrivial. Elaborations are welcome.
Well, the wikipedia indeed speak about signals, and this method indeed is most used in electronics.
The equivalent physic for a Proportional Derivative controller is the mass spring damper controller. The proportional gain is equivalent to the spring gain (it send back the body to the desired position), the derivative gain will try to give the rigid body the same speed as the desired one (which means that when the speed is null, it will act in the same way than a damper).
The computation for the force you should apply to obtain the desired position and speed gives something that looks like this:
Code:
F = mass/dt² * (desiredPosition-realPosition) + mass/dt * (desiredSpeed-realPosition)
But physics never really goes the way you want as there are other force that may be applied to our system, so usually you simplify it to
Code:
F = K * (desiredPosition-realPosition) + B * (desiredSpeed-realPosition)
and you have to fine tune your K and B parameters, but you will usually have B almost equal to K*dt...
Using higher value for K will tend to make the desired position reached faster, but with more oscillations.
Higher values of B should 'damp' this, but will also increase the time before the desired position is reached.
The wikipedia article shows good graphics of what you may obtain with different values of K and B :
http://en.wikipedia.org/wiki/DampingMaxDZ8 wrote:
Not exactly because 0 mass is effectively infinite mass as far as I've understood.
Nonetheless, Thinking at this better, I think it is reasonable to mandate positive nonzero mass for everything that needs simulation.
Therefore, the movement vector can be transformed into an appropriate force vector.
Looks more and more like the PID controller I was speaking about, isn't it ?
MaxDZ8 wrote:
I am still not sure this matches intended behavior. The current movement vector is supposed to be independent from acceleration. It appears I would need to zero out the acceleration next tick by providing an opposite value through applyCentralForce.
Why would you need to zero out the acceleration next tick ? The
applyCentralForce method apply a force only for the tick you call it, nothing else after that. Only the gravity is applied at each tick.