I'm having trouble trying to add a critically damped harmonic oscillator (spring/PD-controller) constraint to my simulator, and the references I've found are somewhat conflicting. Currently I'm using regular PD controllers outside of the solver (i.e the controllers are driving motor torques) and it's proving quite difficult to get well-behaving results, especially when the environment varies.
The original reference is here, which describes using CFM/ERP terms to simulate given P and D values: http://ode.org/ode-0.5-userguide.html#sec_3_8_2
My solver is based on the PBD/Kalman Filter as presented by Antonio on this board (R and S terms correspond to CFM and ERP respectively): http://www.bulletphysics.com/Bullet/php ... =cfm#p6001
Basically I'm unable to figure out what the correct formula is for calculating CFM/ERP values which will produce a critically damped spring; I've also got no clue as to where to begin deriving my own, as it seems to depend on the integrator as well as the constraint solver..
ODE gives (h is timestep, P and D are spring and damping coefficients):
Code: Select all
CFM = 1 / (D + h*P)
ERP = h*P / (D + h*P)
Code: Select all
CFM = 1 / (h*D + h*h*P)
ERP = C * h*P / (h*D + h*h*P)
Code: Select all
kp = P / (1 + h*D + h*h*P)
kd = (D + h*P) / (1 + h*D + h*h*P)
The above would allow the simulation of a harmonic oscillator; a critically damped oscillator requires additional calculation of appropriate P and D terms. An alternate parameterization of PD controllers (frequency+damping rather than spring coefficients ks+kd) is presented in Box2D and Wu's presentation:
Box2D:
Code: Select all
P = 4 * pi*pi * mass * frequency*frequency
D = 4 * pi * mass * damping * frequency
Code: Select all
P = 9 * frequency*frequency
D = 4.5 * damping * frequency
