// ToDo: Replace sqrt_controller with optimal acceleration and jerk limited curve
// MIN(_Dxy_max, _D2xy_max / _kxy_P) limits the max accel to the point where max jerk is exceeded
returnsqrt_controller(error,_kp,_lim_D_Out,_dt);
returnsqrt_controller(_error,_kp,_D1_max,_dt);
}
// set limits on error, output and output from D term
// in normal use the lim_err_min and lim_out_min will be negative
// set_limits - sets the maximum error to limit output and first and second derivative of output
// when using for a position controller, lim_err will be position error, lim_out will be correction velocity, lim_D will be acceleration, lim_D2 will be jerk
// set_limits - sets the maximum error to limit output and first and second derivative of output
// when using for a position controller, lim_err will be position error, lim_out will be correction velocity, lim_D will be acceleration, lim_D2 will be jerk