46 return std::min(std::max(min, x), max);
53 bool has_velocity_limits,
54 bool has_acceleration_limits,
58 double min_acceleration,
59 double max_acceleration,
63 : has_velocity_limits(has_velocity_limits)
64 , has_acceleration_limits(has_acceleration_limits)
65 , has_jerk_limits(has_jerk_limits)
66 , min_velocity(min_velocity)
67 , max_velocity(max_velocity)
68 , min_acceleration(min_acceleration)
69 , max_acceleration(max_acceleration)
83 return tmp != 0.0 ? v / tmp : 1.0;
95 return tmp != 0.0 ? v / tmp : 1.0;
100 const double tmp = v;
107 const double dv =
clamp(v - v0, dv_min, dv_max);
112 return tmp != 0.0 ? v / tmp : 1.0;
117 const double tmp = v;
121 const double dv = v - v0;
122 const double dv0 = v0 - v1;
124 const double dt2 = 2. * dt * dt;
126 const double da_min =
min_jerk * dt2;
127 const double da_max =
max_jerk * dt2;
129 const double da =
clamp(dv - dv0, da_min, da_max);
134 return tmp != 0.0 ? v / tmp : 1.0;
bool has_acceleration_limits
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_acceleration(double &v, double v0, double dt)
Limit the acceleration.
T clamp(T x, T min, T max)
double limit_velocity(double &v)
Limit the velocity.
double limit_jerk(double &v, double v0, double v1, double dt)
Limit the jerk.
double limit(double &v, double v0, double v1, double dt)
Limit the velocity and acceleration.