Exercises - Basic

Important

Windows users should add the command VisualStudioSelect("20XX") (2017, 2019, 2022 are supported) before running the optimal control problem from Maple© (for instance before running the command launchSolver). The command VisualStudioSelect will initialize the right compiling environment in the Windows command prompt opened by Maple©.

DIDO problem 4.1

We consider the equations of motion of a single mass moving with linear motion with velocity \(v\) and subjected to an acceleration \(a\):

(16)\[\frac{\mathrm{d}}{\mathrm{d}t}x(t) = x(t) +u(t)\]

We impose some boundary conditions on the problem:

(17)\[\begin{aligned} \textrm{Initial conditions} & \qquad \textrm{Final conditions} \\[0.5em] x(0) = 1 & \qquad \textrm{none} \end{aligned}\]

The goal of the optimal control problem is to minimise the following

target:

(18)\[\mathrm{minimise}\quad J[x,u] = \frac{x_f^2}{2}+\frac{1}{2}\int_{t_0}^{t_f}u^2 \,\mathrm{d} t\]

the final time \(t_f\) is given and equal to 1.

Cart pole swing-up

The system comprises a cart that travels along a horizontal track and a pendulum that hangs freely from the cart. There is a motor that drives the cart forward and backward along the track. It is possible to move the cart in such a way that the pendulum, initially hanging below the cart at rest, is swung up to a point of inverted balance above the cart. The objectiove is to compute the minimum-force trajectory to perform this so-called ‘swing-up’ maneuver.

The cart-pole is a second-order dynamical system with the following equations:

(19)\[\begin{align*} \dot{q}_1(t) &= v_1(t) \\[0.5em] \dot{q}_2(t) &= v_2(t) \\[0.5em] \dot{v}_1(t) &= \frac{L\,m_2\sin(q_2)v_2^2+u(t)+m_2 g \cos(q_2)\sin(q_2)} {m_1+m_2(1-\cos(q_2)^2)} \\[0.5em] \dot{v}_2(t) &= -\frac{L\,m_2\cos(q_2)\sin(q_2)v_2^2+u \cos(q_2)+(m_1+m_2)g\sin(q_2)} {L\,m_1+l\,m_2(1-\cos(q_2)^2} \end{align*}\]

with the boundary conditions:

(20)\[\begin{align*} q_1(0) &= 0 & q_1(T) &= d \\[0.5em] q_2(0) &= 0 & q_1(T) &= \pi \\[0.5em] v_1(0) &= 0 & v_1(T) &= 0 \\[0.5em] v_2(0) &= 0 & q_1(T) &= 0 \end{align*}\]

and the function to be minimised is:

(21)\[\min\limits_{\boldsymbol{u}} \hspace{0.1cm}&\boldsymbol{J} = \int_{0}^T \,u(t)^2 \, \text{d} t\]

subject to the following constraints:

(22)\[\begin{align*} -d_{\max} &\le q_1(t) \le d_{\max} \\[0.5em] -u_{\max} &\le u(t) \le u_{\max} \end{align*}\]

The problem parameters are \(=2(m)\) and \(u_{\max} = 20 (N)\)

Table 2 Cart pole parameters

Parameter

Value

Units

\(g\)

\(9.81\)

\((m/s^2)\)

\(m_1\)

\(1\)

\((kg)\)

\(m_2\)

\(0.3\)

\((kg)\)

\(L\)

\(0.5\)

\((m)\)

\(d\)

\(1\)

\((m)\)

\(d_{\max}\)

\(2.0\)

\((m)\)

\(u_{\max}\)

\(20\)

\((Nm)\)

Try to solve the problem for different values of final time. Start with \(T = 2(s)\) and then reduce to \(T = 1.5(s)\) and \(T = 1.0(s)\). Analyse what happens.

Animation of the swing up manoeuver obtained