I'm trying to formulate an optimal control problem based off of this given Minimum-Time Cost Function: $$J(t_f)=\frac{1}{2}[x(t_f)-x_{des}(t_f)]^TP_f[x(t_f)-x_{des}(t_f)] + \frac{1}{2}\int_{t_0}^{t_f}(1+[x^t(t)Qx(t)+u^T(t)Ru(t)])dt$$ $$ \text{ where } x=\begin{bmatrix}V\\\gamma\\h\\r\end{bmatrix}P_f\in\mathbb{R}^{4x4}, Q\in\mathbb{R}^{4x4}, Q_x\in\mathbb{R}^{4x4}, R=\begin{bmatrix}1\end{bmatrix}\text{ and } u=\theta=\text{Pitch angle}$$
I would like to minimize the time for a small RC aircraft to go from takeoff at time $t_0$ to cruise in the shortest amount of time $t_f$. I think that there are basically 2 approaches to solving this.
- I can use the ACADO Matlab toolkit to solve the function in this form. I've tried doing this and I cannot seem to understand ACADO well enough to solve it.
- First time-discretize the cost function to put the function in a form which can be solved using another Matlab toolkit such as YALMIP.
Seeing as I've failed on approach #1, I would like to try approach #2. However, I do not understand how to time-discretize this function. I've tried looking through textbooks for how to solve these problems, but I cannot find any text that gives a method to discretize a function like this into a form which can be solved with a solver.
I have initial and final constraints, and have the state space model, but do not really know how to proceed from here $$\dot{x}=\begin{bmatrix}\dot{V}=\frac{1}{m}(Tcos(u-\gamma)-D-mgsin(\gamma)\\\dot{\gamma}=\frac{1}{mV}(Tsin(u-\gamma)+L-mgcos(\gamma)\\\dot{h}=Vsin(\gamma)\\\dot{r}=Vcos(\gamma)\end{bmatrix}$$
I've read that I may need to solve for the Hamiltonian, but I don't understand why, and still would not understand how to proceed solving the problem in matlab once I would solve for it.