testdd cbloom March 2008 Esc = exit +/- = change modes (on numpad) space = pause # keys = select mode # Modes are : 0= "cubic interpolator", 1= "cubic maxaccel", 2 = "hybrid cubic" 3= "PD critical", 4= "PD overdamp", 5= "PD transition to linear", 6= "PD blend with linear", 7= "PID" 8 = "PD clamped" 9 = "AI / piecewise quadratic" This is a lerper/controller test The square changes color when it hits target Use space bar to pause to see how it responds to discontinuous target jumps ------------------------------------------------ The pref.txt file : class MyPref:{ track_time:2 seconds to try to reach target - applies to all modes overdamp_damping:1.75 damping for mode 3 (1.0 is critical) mode0_distance_scale : 50 distance scale for converge time extend lerptransition_distance:16 mode 4 switch distance lerpblend_distance:60 mode 5 blend distance ; outside this distance it's 100% PD lerpblend_damping:1.5 mode 5 damping on the PD (1.0 is critical) lerpblend_lerpspeed:120 mode 5 speed of the lerp part PID_K:1.0 PID_I:0.0 PID_D:1.0 parameters for the PID K is overall gain I is unitless weight of the integrated error D is unitless derivative weight (1,0,1) makes it a critically damped PD cubic_maxaccel : mode 1 max acceleration this is actually a distance, it will be divided by track_time^2 } ------------------------------------------------ 0= "cubic interpolator", This method solves a cubic (aka a bezier) to take you from current pos & vel to the target pos & vel. The cubic is exactly constrained by those 4 conditions. The cubic will get you there in exactly time T. (T = track_time). The cubic is remade every frame from current conditions, there is no stored state. As long as the target is still, T -= dt. (you advance along the curve) When the target moves, T = track_time. (the curve is reset). In theory you could do something where if the target barely moves, T only gets a little longer rather than reseting to the full time. 1= "cubic maxaccel", Similar to mode 0 but removes all the hackiness and instead uses the max acceleration constraint. At each time, it finds the cubic curve between the current pos & vel and the target pos & vel. It then solves for the travel time on that curve that will get there without violating the max accel constraint. It then takes a dt step along that curve. If you can get to the target in less than dt without violating max accel, we just go to the target. 2= "hybric cubic" cubic solved to maxaccel, but takes at most track_time if target is still 3= "PD critical", PD controller (damped spring) with critical damping. 4= "PD overdamp", PD controller overdamped to avoid overshoot. In Prefs. PD's have this problem where if they're fast they overshoot, if they don't overshoot they're really slow. The linear blend modes use overdamped PD's so they don't overshoot and then switch or blend to linear to avoid the really slow tail. 5= "PD transition to linear", Overdamped PD controller up to lerptransition_distance, where it switched to linear. Tries to keep velocity magnitude continuous but no gaurantee. 6= "PD blend with linear", Similar to mode 4, but instead of switching at a distance, inside the transition distance it blends between the PD and linear interpolation. 7= "PID" PID is theoretically more tuneable than a PD but hard to work with. From reading the literature on PID's briefly, they are inherently much harder to tweak. In fact, there's a bunch of literature on using fuzzy logic feedback loops to adaptively tune them which sounds just awful. The parameters for a PID that give you good behavior are data-dependent. So all the fancy tweakage to make them behave well depends on feeding them in a certain way, and if you feed the same thing a different input signal it could behave really badly. 8 = "PD clamped" PD with a min vel & max accel clamp min vel makes it move linearly near the end max accel makes it not accelerate really hard at the start 9 = "AI / piecewise quadratic" quadratic accel phase linear maxvel move quadratic decel phase sort of like the standard way of making AI steer to a target