[Physics] the best path for a given initial and final state

accelerationjerkkinematicsoptimizationvariational-principle

I am trying to calculate an efficient acceleration curve given starting and final positions and velocities. I'm assuming no friction, and that the acceleration can be applied in any direction at any time.

Given:

  • $p_0$ = starting position
  • $v_0$ = starting velocity
  • $p_f$ = final position
  • $v_f$ = final velocity
  • $T$= total time

I want to find a nice $a(t)$ function that will produce final conditions.

So far I have the following solution that works, but produces an incredibly inefficient $a(t)$ curve:

First I calculate the constant acceleration required to get from $v_{0}$ to $v_{f}$ :

$$ a_v = \cfrac{v_f – v_{0}}{T} $$

Then I calculate the change in position this acceleration will create over $T$ :

$$ p_v = \cfrac{1}{2} a_v T^2 $$

Next I calculate the average velocity required to get from $p_{0}$ to $p_f$ and to counteract $p_v$ :

$$ v_p = \cfrac{p_f – (v_{0} + p_f ) }{ T } $$

Next I calculate the acceleration needed to produce this average velocity over the total time:

$$ a_p= \cfrac{2 v_p}{ T} $$

Finally, I add twice that acceleration to the first half of my acceleration function, and subtract twice that acceleration from the second half. This produces the net position change that I want, but has a net $0$ velocity/acceleration change so $v_f$ stays correct:

$$ a(t) = \begin{cases} a_v + 2 a_p & t \leq \frac T 2 \\
a_v – 2 a_p & t > \frac T 2 \end{cases} $$

While this solution provides a result, it can cause the simulated objects I'm working with to move backward before moving toward their final goal, along with other weird behavior. I think the ideal solution would minimize total acceleration applied over time (and thus force, since the mass of the object will stay constant over this time).

I know that the constraints on this problem are that the integral of $a(t)$ must equal $v_f – v_{0} $, and that the integral of that integral must equal $p_f – p_0$ . I just don't know how to setup the problem to solve for those constraints. I don't even really know what I should Google for to try and solve this problem. Any help would be greatly appreciated.

Best Answer

Let us try Ross Millikan's suggestion, cf. his comment above: Let us minimize the (higher-order) functional

$$\tag{1} S~:=~ \frac{1}{2}\int_{t_i}^{t_f} \!dt~ a^2, \qquad a~\equiv~\dot{v},\qquad v~\equiv~\dot{x}, $$

with fixed endpoints

$$\tag{2} x(t_i)~=~x_i , \qquad v(t_i)~=~v_i , \qquad x(t_f)~=~x_f , \qquad v(t_f)~=~v_f , $$

and with fixed initial and final times, $t_i$ and $t_f$. Let $j\equiv\dot{a}$ denote the jerk. An infinitesimal variation of the functional $S$ yields

$$ \delta S~=~\int_{t_i}^{t_f} \! dt~ a \delta a~\stackrel{\text{int. by parts}}{=}~ \int_{t_i}^{t_f} \!dt~\frac{dj}{dt} \delta x +\left[ a \underbrace{\delta v}_{=0} - j \underbrace{\delta x}_{=0}\right]^{t_f}_{t_i} $$ $$\tag{3} ~\stackrel{(2)}{=}~\int_{t_i}^{t_f} \!dt~\frac{dj}{dt} \delta x. $$ The higher-order Euler-Lagrange equation becomes

$$\tag{4} \frac{dj}{dt}~=~0, $$

cf. the fundamental lemma of calculus of variations. In other words, the jerk

$$\tag{5} j~=~A$$

should be a constant of motion; the acceleration

$$\tag{6} a(t)~=~At+B$$

should be an affine function in $t$; the velocity

$$\tag{7} v(t)~=~\frac{A}{2} t^2+ Bt +C $$

is a quadratic polynomial in $t$; while the position

$$\tag{8} x(t)~=~\frac{A}{6} t^3+ \frac{B}{2}t^2+Ct +D$$

is a cubic polynomial in $t$. Thus we arrive at the (cubic) spline fitting problem mentioned in Floris' answer: Four linear equations (2) with four unknowns $(A,B,C,D)$. To solve them, notice the similarity between the two formulas

$$ \tag{9} \frac{v_i+v_f}{2}~\stackrel{(2)+(7)}{=}~\frac{A}{4}(t_i^2+t_f^2)+B\frac{t_i+t_f}{2}+C $$

and

$$ \tag{10} \frac{\Delta x}{\Delta t}~\stackrel{(2)+(8)}{=}~\frac{A}{6}(t_i^2+t_it_f+t_f^2)+B\frac{t_i+t_f}{2}+C. $$

The difference of (9) and (10) depends only on one unknown $A$! Here we have defined

$$\tag{11} \Delta t ~:=~ t_f-t_i, \qquad \Delta x ~:=~ x_f-x_i\quad\text{and} \quad\Delta v ~:=~ v_f-v_i.$$

The jerk and average acceleration become

$$ \tag{12} j~\stackrel{(5)}{=}~A~\stackrel{(9)+(10)}{=}~6\frac{v_i+v_f}{(\Delta t)^2}-12\frac{\Delta x}{(\Delta t)^3}$$

and

$$ \tag{13} \langle a\rangle ~:=~\frac{\int_{t_i}^{t_f} \! dt~ a}{\Delta t} ~\stackrel{(6)}{=}~A\frac{t_i+t_f}{2}+B~\stackrel{(2)+(7)}{=}~\frac{\Delta v}{\Delta t}, $$

respectively. Similarly, the remaining unknowns $B$, $C$, and $D$ can now easily be determined uniquely in terms of the boundary conditions (2).

Related Question