\( \DeclareMathOperator{\abs}{abs} \)

SEG1234567 x0 is the initial position v0 is the initial velocity a0 is the initial acceleration x7 is the final position v7 is the final velocity a7 is the final acceleration v is the command velocity a is the command acceleration d is the command deceleration j is the command jerk t01 is the time from point x0 to point x1 t12 is the time from point x1 to point x2 ...

--> remvalue(all)$
eq0: x0+v0*t01+(a0/2)*t01^2+(j/6)*t01^3=x1$ /* Segment 1.  Jerk = +j            */
eq1: v0+a0*t01+(j/2)*t01^2=v1$
eq2: a0+j*t01=a1$

eq3: x1+v1*t12+(a1/2)*t12^2=x2$             /* Segment 2.  Acceleration=a Jerk=0   */
eq4: v1+a1*t12=v2$

eq5: x2+v2*t23+(a2/2)*t23^2-(j/6)*t23^3=x3$ /* Segment 3.  Jerk=-j  */
eq6: v2+a2*t23-(j/2)*t23^2=v3$
eq7: a2-j*t23=a3$

eq8: x3+v3*t34=x4$                          /* Segment 4. Velocity=v Acceleration=0 Jerk=0 */

eq9: x4+v*t45+(a4/2)*t45^2-(j/6)*t45^3=x5$  /* Segment 5. Jerk = -j  */
eq10: v4+a4*t45-(j/2)*t45^2=v5$
eq11: a4-j*t45=a5$

eq12: x5+v5*t56+(a5/2)*t56^2=x6$            /* Segment 6. Acceleration = -d  Jerk=0 */
eq13: v5+a5*t56=v6$

eq14: x6+v6*t67+(a6/2)*t67^2+(j/6)*t67^3=x7$ /* Segment 7. Jerk = +j */
eq15: v6+a6*t67+(j/2)*t67^2=v7$
eq16: a6+j*t67=a7$
/* Calculate the total time symbolically    */
eq17: t07=t01+t12+t23+t34+t45+t56+t67$

Solve the for the 17 unknowns using the 17 equations The results are a list of equations for each of the variables wxMaxima has a problem exporting one all all of these equations.

--> subst([a1=a,a2=a,v3=v,a3=0,v4=v,a4=0,a5=-d,a6=-d,v7=0,a7=0],
     [eq0,eq1,eq2,eq3,eq4,eq5,eq6,eq7,eq8,eq9,eq10,eq11,eq12,eq13,eq14,eq15,eq16,eq17])$
solve(%,[t01,x1,v1,t12,x2,v2,t23,x3,t34,x4,t45,x5,v5,t56,x6,v6,t67,t07])$
eq18: %[1]$                                 /* Keep the first and only solution */
for i thru length(eq18) do ldisp(eq18[i])$
\[\mathrm{\tt (\%t255) }\quad \mathit{t01}=-\frac{\mathit{a0}-a}{j}\]\[\mathrm{\tt (\%t256) }\quad \mathit{x1}=\frac{{{a}^{3}}-3\cdot a\cdot {{\mathit{a0}}^{2}}+2\cdot {{\mathit{a0}}^{3}}+\left( 6\cdot a-6\cdot \mathit{a0}\right) \cdot j\cdot \mathit{v0}+6\cdot {{j}^{2}}\cdot \mathit{x0}}{6\cdot {{j}^{2}}}\]\[\mathrm{\tt (\%t257) }\quad \mathit{v1}=\frac{{{a}^{2}}-{{\mathit{a0}}^{2}}+2\cdot j\cdot \mathit{v0}}{2\cdot j}\]\[\mathrm{\tt (\%t258) }\quad \mathit{t12}=-\frac{2\cdot {{a}^{2}}-{{\mathit{a0}}^{2}}-2\cdot j\cdot v+2\cdot j\cdot \mathit{v0}}{2\cdot a\cdot j}\]\[\mathrm{\tt (\%t259) }\quad \mathit{x2}=\frac{4\cdot {{a}^{4}}-6\cdot {{a}^{2}}\cdot {{\mathit{a0}}^{2}}+8\cdot a\cdot {{\mathit{a0}}^{3}}-3\cdot {{\mathit{a0}}^{4}}-12\cdot {{a}^{2}}\cdot j\cdot v+12\cdot {{j}^{2}}\cdot {{v}^{2}}+\left( 12\cdot {{\mathit{a0}}^{2}}-24\cdot a\cdot \mathit{a0}+12\cdot {{a}^{2}}\right) \cdot j\cdot \mathit{v0}-12\cdot {{j}^{2}}\cdot {{\mathit{v0}}^{2}}+24\cdot a\cdot {{j}^{2}}\cdot \mathit{x0}}{24\cdot a\cdot {{j}^{2}}}\]\[\mathrm{\tt (\%t260) }\quad \mathit{v2}=\frac{2\cdot j\cdot v-{{a}^{2}}}{2\cdot j}\]\[\mathrm{\tt (\%t261) }\quad \mathit{t23}=\frac{a}{j}\]\[\mathrm{\tt (\%t262) }\quad \mathit{x3}=\frac{-6\cdot {{a}^{2}}\cdot {{\mathit{a0}}^{2}}+8\cdot a\cdot {{\mathit{a0}}^{3}}-3\cdot {{\mathit{a0}}^{4}}+12\cdot {{a}^{2}}\cdot j\cdot v+12\cdot {{j}^{2}}\cdot {{v}^{2}}+\left( 12\cdot {{\mathit{a0}}^{2}}-24\cdot a\cdot \mathit{a0}+12\cdot {{a}^{2}}\right) \cdot j\cdot \mathit{v0}-12\cdot {{j}^{2}}\cdot {{\mathit{v0}}^{2}}+24\cdot a\cdot {{j}^{2}}\cdot \mathit{x0}}{24\cdot a\cdot {{j}^{2}}}\]\[\mathrm{\tt (\%t263) }\quad \mathit{t34}=\frac{\left( 3\cdot {{\mathit{a0}}^{4}}-8\cdot a\cdot {{\mathit{a0}}^{3}}+6\cdot {{a}^{2}}\cdot {{\mathit{a0}}^{2}}\right) \cdot d+\left( -12\cdot a\cdot {{d}^{2}}-12\cdot {{a}^{2}}\cdot d\right) \cdot j\cdot v+\left( -12\cdot d-12\cdot a\right) \cdot {{j}^{2}}\cdot {{v}^{2}}+\left( -12\cdot {{\mathit{a0}}^{2}}+24\cdot a\cdot \mathit{a0}-12\cdot {{a}^{2}}\right) \cdot d\cdot j\cdot \mathit{v0}+12\cdot d\cdot {{j}^{2}}\cdot {{\mathit{v0}}^{2}}-24\cdot a\cdot d\cdot {{j}^{2}}\cdot \mathit{x0}+24\cdot a\cdot d\cdot {{j}^{2}}\cdot \mathit{x7}}{24\cdot a\cdot d\cdot {{j}^{2}}\cdot v}\]\[\mathrm{\tt (\%t264) }\quad \mathit{x4}=\frac{-{{d}^{2}}\cdot v-j\cdot {{v}^{2}}+2\cdot d\cdot j\cdot \mathit{x7}}{2\cdot d\cdot j}\]\[\mathrm{\tt (\%t265) }\quad \mathit{t45}=\frac{d}{j}\]\[\mathrm{\tt (\%t266) }\quad \mathit{x5}=\frac{-{{d}^{4}}+3\cdot {{d}^{2}}\cdot j\cdot v-3\cdot {{j}^{2}}\cdot {{v}^{2}}+6\cdot d\cdot {{j}^{2}}\cdot \mathit{x7}}{6\cdot d\cdot {{j}^{2}}}\]\[\mathrm{\tt (\%t267) }\quad \mathit{v5}=\frac{2\cdot j\cdot v-{{d}^{2}}}{2\cdot j}\]\[\mathrm{\tt (\%t268) }\quad \mathit{t56}=\frac{j\cdot v-{{d}^{2}}}{d\cdot j}\]\[\mathrm{\tt (\%t269) }\quad \mathit{x6}=\frac{6\cdot {{j}^{2}}\cdot \mathit{x7}-{{d}^{3}}}{6\cdot {{j}^{2}}}\]\[\mathrm{\tt (\%t270) }\quad \mathit{v6}=\frac{{{d}^{2}}}{2\cdot j}\]\[\mathrm{\tt (\%t271) }\quad \mathit{t67}=\frac{d}{j}\]\[\mathrm{\tt (\%t272) }\quad \mathit{t07}=\frac{\left( 3\cdot {{\mathit{a0}}^{4}}-8\cdot a\cdot {{\mathit{a0}}^{3}}+6\cdot {{a}^{2}}\cdot {{\mathit{a0}}^{2}}\right) \cdot d+\left( 12\cdot a\cdot {{d}^{2}}+\left( 12\cdot {{a}^{2}}-24\cdot a\cdot \mathit{a0}+12\cdot {{\mathit{a0}}^{2}}\right) \cdot d\right) \cdot j\cdot v+\left( 12\cdot d+12\cdot a\right) \cdot {{j}^{2}}\cdot {{v}^{2}}+\left( \left( -12\cdot {{a}^{2}}+24\cdot a\cdot \mathit{a0}-12\cdot {{\mathit{a0}}^{2}}\right) \cdot d\cdot j-24\cdot d\cdot {{j}^{2}}\cdot v\right) \cdot \mathit{v0}+12\cdot d\cdot {{j}^{2}}\cdot {{\mathit{v0}}^{2}}-24\cdot a\cdot d\cdot {{j}^{2}}\cdot \mathit{x0}+24\cdot a\cdot d\cdot {{j}^{2}}\cdot \mathit{x7}}{24\cdot a\cdot d\cdot {{j}^{2}}\cdot v}\]

x0  Initial position v0  Initial velocity a0  Initial acceleration x7  Final position v7  Final velocity a7  Final acceleration v   Commanded velocity a   Commanded acceleration d   Commanded deceleration j   Commanded jerk

--> x0: 0.0$
v0: 4.0$
a0: -100.0$
x7: 4.0$
v7: 0.0$
a7: 0.0$
v: 10.0$
a: 100.0$
d: 100.0$
j: 4000.0$

Evaluate the all the equations is the list Assigning the values to the variables This avoids having to cut and paste equations to make assignments. Display the values of all the variables.

--> eq20: ''(eq18)$ /* Evaluate the list of equations */
map(lambda([u],lhs(u)::rhs(u)),%)$
for i thru length(eq20) do ldisplay(eq20[i])$
\[\mathrm{\tt (\%t285) }\quad \mathit{t01}=0.05\]\[\mathrm{\tt (\%t286) }\quad \mathit{x1}=0.1583333333333333\]\[\mathrm{\tt (\%t287) }\quad \mathit{v1}=4.0\]\[\mathrm{\tt (\%t288) }\quad \mathit{t12}=0.0475\]\[\mathrm{\tt (\%t289) }\quad \mathit{x2}=0.4611458333333333\]\[\mathrm{\tt (\%t290) }\quad \mathit{v2}=8.75\]\[\mathrm{\tt (\%t291) }\quad \mathit{t23}=0.025\]\[\mathrm{\tt (\%t292) }\quad \mathit{x3}=0.7007291666666666\]\[\mathrm{\tt (\%t293) }\quad \mathit{t34}=0.2674270833333334\]\[\mathrm{\tt (\%t294) }\quad \mathit{x4}=3.375\]\[\mathrm{\tt (\%t295) }\quad \mathit{t45}=0.025\]\[\mathrm{\tt (\%t296) }\quad \mathit{x5}=3.614583333333333\]\[\mathrm{\tt (\%t297) }\quad \mathit{v5}=8.75\]\[\mathrm{\tt (\%t298) }\quad \mathit{t56}=0.07500000000000001\]\[\mathrm{\tt (\%t299) }\quad \mathit{x6}=3.989583333333333\]\[\mathrm{\tt (\%t300) }\quad \mathit{v6}=1.25\]\[\mathrm{\tt (\%t301) }\quad \mathit{t67}=0.025\]\[\mathrm{\tt (\%t302) }\quad \mathit{t07}=0.5149270833333334\]

Compute the times at the beginning and end of each segment

--> 't0=t0: 0;
't1=t1: t0+t01;
't2=t2: t1+t12;
't3=t3: t2+t23;
't4=t4: t3+t34;
't5=t5: t4+t45;
't6=t6: t5+t56;
't7=t7: t6+t67;
't8=t8: t7+0.1;
\[\mathrm{\tt (\%o303) }\quad \mathit{t0}=0\]\[\mathrm{\tt (\%o304) }\quad \mathit{t1}=0.05\]\[\mathrm{\tt (\%o305) }\quad \mathit{t2}=0.0975\]\[\mathrm{\tt (\%o306) }\quad \mathit{t3}=0.1225\]\[\mathrm{\tt (\%o307) }\quad \mathit{t4}=0.3899270833333334\]\[\mathrm{\tt (\%o308) }\quad \mathit{t5}=0.4149270833333334\]\[\mathrm{\tt (\%o309) }\quad \mathit{t6}=0.4899270833333334\]\[\mathrm{\tt (\%o310) }\quad \mathit{t7}=0.5149270833333334\]\[\mathrm{\tt (\%o311) }\quad \mathit{t8}=0.6149270833333333\]

Compute the position, velocity and acceleration for all the motion segments

--> pva(t):= (
   if t<t01 then
       ( t: t-t0, [x0+v0*t+(a0/2)*t^2+(j/6)*t^3, v0+a0*t+(j/2)*t^2,a0+j*t] )
   elseif t1<=t and t<t2 then
       ( t: t-t1, [ x1+v1*t+(a/2)*t^2,v1+a*t,a ] )
   elseif t2<=t and t<t3 then
       ( t: t-t2, [x2+v2*t+(a/2)*t^2-(j/6)*t^3, v2+a*t-(j/2)*t^2, a-j*t] )
   elseif t3<=t and t<t4 then
       ( t: t-t3, [x3+v*t, v, 0 ] )
   elseif t4<=t and t<t5 then
       ( t: t-t4, [ x4+v*t-(j/6)*t^3, v-(j/2)*t^2, -j*t] )
   elseif t5<=t and t<t6 then
       ( t: t-t5, [ x5+v5*t-(d/2)*t^2, v5-d*t, -d ] )
   elseif t6<=t and t<t7 then
       ( t: t-t6, [ x6+v6*t-(d/2)*t^2+(j/6)*t^3,v6-d*t+(j/2)*t^2, -d+j*t ] )
   else
       ( t: t-t7, [ x7+v7*t+(a7/2)*t^2 ,v7+a7*t,a7 ] )
)$

Plot the position, velocity and acceleration for all the motion segments

--> wxplot2d(pva(t)[1],[t,t0,t8],[xlabel,"Time"],[ylabel,"Position"],[legend,"Postion"]);
wxplot2d(pva(t)[2],[t,t0,t8],[xlabel,"Time"],[ylabel,"Velocity"],[legend,"Velocity"]);
wxplot2d(pva(t)[3],[t,t0,t8],[xlabel,"Time"],[ylabel,"Acceleration"],[legend,"Acceleration"]);
\[\mathrm{\tt (\%t313) }\quad \]  (Graphics) \[\mathrm{\tt (\%o313) }\quad \]\[\mathrm{\tt (\%t314) }\quad \]  (Graphics) \[\mathrm{\tt (\%o314) }\quad \]\[\mathrm{\tt (\%t315) }\quad \]  (Graphics) \[\mathrm{\tt (\%o315) }\quad \]
Created with wxMaxima.