Let us consider a wagon moving along a rail, whom acceleration can be controlled by a force
<img src="./assets/chariot.png" style="display: block; margin: 0 auto 20px auto;" width="300px">
We assume that the mass is constant and unitary and that there is no friction. The dynamics we consider is given by
which is simply the double integrator system.
Les us consider a transfer starting at time
starting from the condition
!!! note "Solution and details"
See the page
[Double integrator: energy minimisation](https://control-toolbox.org/docs/ctproblems/stable/problems/double_integrator_energy.html#DIE)
for the analytical solution and details about this problem.
using Plots
using Plots.PlotMeasures
plot(args...; kwargs...) = Plots.plot(args...; kwargs..., leftmargin=25px)
First, we need to import the OptimalControl.jl
package:
using OptimalControl
Then, we can define the problem
@def ocp begin
t ∈ [ 0, 1 ], time
x ∈ R², state
u ∈ R, control
x(0) == [ -1, 0 ]
x(1) == [ 0, 0 ]
ẋ(t) == [ x₂(t), u(t) ]
∫( 0.5u(t)^2 ) → min
end
nothing # hide
Solve it
sol = solve(ocp)
nothing # hide
and plot the solution
plot(sol, size=(600, 450))