# Unreachable Velocity in Jerk Limited Trajectory

I've recently been developing a jerk limited trajectory algorithm. I've gone through all the analytical solutions for every profile to find the time optimal solution, and then quantized to the nearest time cycle by adjusting the jerk within the user defined limits, all is good with that.

The real problem arises when I encounter one specific case, if the distance is too small to make the desired change from start to end velocity. I've solved for the adjusted final velocity which is perfect for the time optimal case, but some scenarios arise where I cannot quantize to my time cycle. I've tried adjusting the jerk, sometimes it works, sometimes no solution exists (the final velocity goes outside the inputted bounds). I've tried adjusting/lowering the change in velocity and adding a coasting period onto the end, sometimes it works, sometimes this final velocity is outside the bounds as well. I've also tried lowering the max acceleration to make the movement slightly longer, again, sometimes it works, sometimes the acceleration exceeds limits. I've also tried turning of jerk limits completely and moving down to a second order profile, but still similar issues.

All of these methods work in some cases, and in a realtime system I can't afford to check every single one in a single cycle time. I've read countless papers on jerk limited trajectory generation, and I am so close to a perfect solution, but this one edge case has driven me crazy.

To be clear the equations I'm using are

$$T = 2\sqrt{\frac{v_f - v_s}{J}}$$ for cases in which no max acceleration is reached and $$T = \frac{v_f - v_s}{A} + \frac{A}{J}$$ for cases with max acceleration. A is max acceleration, J the jerk limit, T the total movement time, $$v_f$$ and $$v_s$$ the final and starting velocities. The final position can be calculated as $$p_f = \frac{v_s + v_f}{2} T$$ There are many more equations I have used that eventually fail that are derived from these. Again, my main strategy has been to adjust the velocity first to a time T that has no position error and then quantizing to $$T_Q$$ and looking for some Jerk value within the limits, that can produce this motion time, with no position error. The adjusted final velocity can be whatever it needs to be within the inputted $$v_s$$ and $$v_f$$. Solving this analytically yields a very simple equation $$v_f = -v_s + 2p_f / T_Q$$ I feel as though the solution involves simultaneously adjusting $$v_f$$ and J at the same time, but I can't think of a way to implement this in a realtime system. The system requires no overshooting in position, and no exceeding velocity or acceleration limits, jerk limit is open to being turned off if need be, but I would prefer not to. If anyone has any advice or ideas on how to solve this problem it would be greatly appreciated.