I have an optimal control problem as follows:
Minimize
$\int_{0}^{t_f}dt$
Where the state equations are
$\frac{dr}{dt} = v$
$\frac{dv}{dt} = -\frac{1}{r^2} + cos(u) + \frac{r}{\omega^2}$
$\frac{d\theta}{dt} = \omega$
$\frac{d\omega}{dt} = \frac{sin(u) - 2v\omega}{r}$
Subject to initial conditions
$r(0) = R$
$v(0) = 0$
$\theta(0) = 0$
$\omega(0) = 0$
and final conditions
$r(t_f) = R'$
$v(t_f) = 0$
$\theta(t_f) = \theta'$
$\omega(t_f) = \omega'$
Where $u = u(t)$ is the control function, and where $R, R', \theta', \omega'$ are constant and are to be specified by a given situation.
My question revolves around solving this problem numerically given the nature of $t_f$ being free. I have constructed the Hamiltonian and found the co-state differential equations, and have even been able to find that $u(t) = \tan^{-1}(\frac{z_4}{z_2})$ where $z_4$ and $z_2$ are co-state equations. However, I don't know how to go about solving this numerically. I would assume a shooting method would be useful where one changes the initial conditions for the co-state differential equations which determine $u$ and continue shooting until the final condition at $t_f$ are satisfied. The problem is I don't know how to take into consideration that $t_f$ is free as the shooting method heavily depends on this being fixed. From all my reading I haven't been able to find any clues as to how to numerically solve this problem given that $t_f$ is free.
Any help would be appreciated.