Given Max Speed, Max Acceleration and Jerk - How do I calculate time? I'm developing some python code that controls an end effector moving in a two-dimensional plane (XY). It moves through a list of points sequentially and I'd like to estimate the time it will take as precisely as possible.
My constant variables are:
Max_Speed: 30 mm/s
Max_Acceleration: 60 mm/s^2
Max_Jerk: 20 mm/s

For simplicity, we can assume the acceleration curve to be linear. In practice, it's much closer to a sigmoid curve.
For now, let's assume the end-effector will move from the origin to another point.
pt1: 0,0
pt2: 20,20

My current implementation only takes Max speed into account, any improvement would be hugely appreciated. However, given my very limited mathematical background, I'll favour simplicity at the expense of accuracy. A pythonic explanation would also be hugely appreciated.
distance = euclidean_distance(pt1, pt2) = 28.284271
time = distance / Max_Speed =  28.284271 / 30 = 0.9428090333

For the above example, it would be reasonable to assume that the maximum speed was not reached and therefore the calculation is off. The end effector carries a lot of mass, hence the relatively low acceleration value and the assumption that the maximum speed was not reached. 
 A: Based on information in the comments, we are going to assume that the acceleration increases linearly with time, where the slope of this line is given by the maximum jerk $j_{max}$. Therefore:
$$a(t)=j_{max}t$$
Since $a=\dot v$, and $v=\dot x$, we can solve for $v(t)$ and $x(t)$ assuming the end-effector is moving in a straight line with $v(0)=0$ and $x(0)=0$. We will neglect the maximum acceleration and maximum speed for now. If we never reach these thresholds in the calculations, then we do not need to consider these maximum values. If we do reach these maximum values then more work will need to be done.
With the above assumptions:
$$v(t)=\int_0^ta(\tau)d\tau=\frac 12j_{max}t^2$$
$$x(t)=\int_0^tv(\tau)d\tau=\frac 16j_{max}t^3$$
Solving for $t$ when we reach the end position
$$t=\left (\frac{6x_{end}}{j_{max}}\right )^{1/3}=\left (\frac{6(28.28 \space mm)}{20\space mm/s^3}\right )^{1/3}\approx 2.04 \space s$$
Now let's check our acceleration and speed at this time:
$$a(2.04\space s)=40.8\space mm/s^2<a_{max}$$
$$v(2.04\space s)=41.6\space mm/s>v_{max}$$
So you can see that we hit maximum speed after this time interval. Therefore, we need to determine when we hit the maximum speed:
$$t_{v_{max}}=\left(\frac{2v_{max}}{j_{max}}\right )^{1/2}\approx 1.73 \space s$$
At this time I am assuming the acceleration goes to $0$? So therefore after about $1.73\space s$ you need to switch to the object moving at constant speed, which it seems like you already know how to do.
A: Assuming you need to stop at $P_2$ and that de-acceleration and de-jerk are of the same magnitude as acceleration and jerk than you need to find time to midway between $P_1$ and $P_2$ and multiply by two. 
By integrating jerk to obtain acceleration, integrating acceleration to obtain velocity and integrating velocity to obtain distance, you can find that:


*

*Time from $P_1$ to maximum acceleration is $3 sec$. 

*Time from $P_1$ to maximum velocity is $\sqrt3 sec$.


So maximum velocity is the limiting factor. 
During these $\sqrt3 sec$, a distance of $17.3 mm$ is traveled. So for distances $P_1 - P_2$ longer than $17.3 X 2$  $mm$ you should subtract $17.3$ $mm$ from half-distance and use maximum velocity for that reduced distance plus $\sqrt3 sec$.
For distances shorter than $17.3 X 2$  $mm$ , you can use directly use the distance formula to obtain time. 
All of these can easily be applied in Python with the following prescription:


*

*Calculate half the distance (d).

*If d>17.3, calculate $\frac{d-17.3}{V_{max}}$ + $\sqrt3$.

*If d<=17.3, calculate $({\frac{6d}{20}})^{\frac{1}{3}}$.

*Multiply result by 2.
