47 bool has_velocity_limits,
48 bool has_acceleration_limits,
52 double min_acceleration,
53 double max_acceleration,
57 : has_velocity_limits(has_velocity_limits)
58 , has_acceleration_limits(has_acceleration_limits)
59 , has_jerk_limits(has_jerk_limits)
60 , min_velocity(min_velocity)
61 , max_velocity(max_velocity)
62 , min_acceleration(min_acceleration)
63 , max_acceleration(max_acceleration)
77 return tmp != 0.0 ? v / tmp : 1.0;
89 return tmp != 0.0 ? v / tmp : 1.0;
101 const double dv =
clamp(v - v0, dv_min, dv_max);
106 return tmp != 0.0 ? v / tmp : 1.0;
111 const double tmp = v;
115 const double dv = v - v0;
116 const double dv0 = v0 - v1;
118 const double dt2 = 2. * dt * dt;
120 const double da_min =
min_jerk * dt2;
121 const double da_max =
max_jerk * dt2;
123 const double da =
clamp(dv - dv0, da_min, da_max);
128 return tmp != 0.0 ? v / tmp : 1.0;
double limit(double &v, double v0, double v1, double dt)
Limit the velocity and acceleration.
SpeedLimiter(bool has_velocity_limits=false, bool has_acceleration_limits=false, bool has_jerk_limits=false, double min_velocity=0.0, double max_velocity=0.0, double min_acceleration=0.0, double max_acceleration=0.0, double min_jerk=0.0, double max_jerk=0.0)
Constructor.
double limit_velocity(double &v)
Limit the velocity.
bool has_acceleration_limits
double limit_acceleration(double &v, double v0, double dt)
Limit the acceleration.
double limit_jerk(double &v, double v0, double v1, double dt)
Limit the jerk.
T clamp(T x, T min, T max)