pantor / ruckig

Motion Generation for Robots and Machines. Real-time. Jerk-constrained. Time-optimal.
https://ruckig.com
MIT License
640 stars 155 forks source link

Possible error in void Brake::velocity_brake #75

Closed Fubini2 closed 2 years ago

Fubini2 commented 2 years ago

Dear @pantor,

investigating further in a issue we had with the final acceleration prototype I found the following lines of code in the above method

const double t_to_v_max = a0/jMax + std::sqrt(a0*a0 + 2 * jMax * (v0 - vMax)) / std::abs(jMax);
const double t_to_v_min = a0/jMax + std::sqrt(a0*a0 / 2 + jMax * (v0 - vMin)) / std::abs(jMax);

Inside the calculation t_to_v_min should it not be

const double t_to_v_min = a0/jMax + std::sqrt(a0*a0 + 2 + ...

instead of

const double t_to_v_min = a0/jMax + std::sqrt(a0*a0 / 2 + ...

or am I missing here something in the solution of this quadratic equation.

Fubini

pantor commented 2 years ago

The equation for t_to_v_min is the solution of a two-step braking profile with j1 = -jMax and j2 = +jMax. As its second condition, the acceleration after the second step needs to be zero (a2=0), otherwise the velocity limit would be violated afterwards. In Mathematica, the equation system is given by:

Solve[{vMin == (v0 + a0*t1 - 1/2 jMax t1^2) + (a0 - jMax t1)*t2 + 1/2 jMax t2^2, 0 == (a0 - jMax t1) + jMax t2}, {t1, t2}]

Of course, t_to_v_min corresponds to t1.