13 return std::min(std::max(min, x), max);
20 bool has_velocity_limits,
21 bool has_acceleration_limits,
22 bool has_deceleration_limits,
26 double min_acceleration,
27 double max_acceleration,
28 double min_deceleration,
29 double max_deceleration,
33 : has_velocity_limits(has_velocity_limits)
34 , has_acceleration_limits(has_acceleration_limits)
35 , has_deceleration_limits(has_deceleration_limits)
36 , has_jerk_limits(has_jerk_limits)
37 , min_velocity(min_velocity)
38 , max_velocity(max_velocity)
39 , min_acceleration(min_acceleration)
40 , max_acceleration(max_acceleration)
41 , min_deceleration(min_deceleration)
42 , max_deceleration(max_deceleration)
56 return tmp != 0.0 ? v / tmp : 1.0;
68 return tmp != 0.0 ? v / tmp : 1.0;
75 if (fabs(v) > fabs(v0))
82 const double dv =
clamp(v - v0, dv_min, dv_max);
94 const double dv =
clamp(v - v0, dv_min, dv_max);
100 return tmp != 0.0 ? v / tmp : 1.0;
105 const double tmp = v;
109 const double dv = v - v0;
110 const double dv0 = v0 - v1;
112 const double dt2 = 2. * dt * dt;
114 const double da_min =
min_jerk * dt2;
115 const double da_max =
max_jerk * dt2;
117 const double da =
clamp(dv - dv0, da_min, da_max);
122 return tmp != 0.0 ? v / tmp : 1.0;
double limit_jerk(double &v, double v0, double v1, double dt)
Limit the jerk.
double limit_velocity(double &v)
Limit the velocity.
SpeedLimiter(bool has_velocity_limits=false, bool has_acceleration_limits=false, bool has_deceleration_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_deceleration=0.0, double max_deceleration=0.0, double min_jerk=0.0, double max_jerk=0.0)
Constructor.
bool has_deceleration_limits
double limit_acceleration(double &v, double v0, double dt)
Limit the acceleration.
double limit(double &v, double v0, double v1, double dt)
Limit the velocity and acceleration.
T clamp(T x, T min, T max)
bool has_acceleration_limits