[Physics] Given Max Speed, Max Acceleration and Jerk – How to calculate time

computational physicsdistancejerknewtonian-mechanicstime

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.

Best Answer

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.