I want to implement a pseudospectral methods to solve (nonlinear) Optimal Control Problems, for instance
$$J(u)=\int_0^T L(x(t),u(t),t) dt $$
s.t
$$x(t)'=a(x(t),u(t),t)$$ $$x(0)=t_b, x(T)=t_e$$
The approches I found so far, are only give a sketch how to do it. What I need is a clear algorithmn how to approch this. I am not sure If I should take an iterative Scheme like choosing $u_0(t)$ and then solve the Integral and ODE seperatly, which leads to an nonlinear OP, or should I first build the Hamiliton? I would be thankful for Tipps and reference to some papers which make it clear for me. Thank you.
You may check papers by A.Rao, e.g., this one or an introductory tutorial by M. Kelly.
In general, before starting you should first decide whether you wish to implement a direct or an indirect optimal control method. The latter will involve writing down the system of $2n$ Hamiltonian equations and solving it numerically while the former attempts to find an optimal solution by direct minimization of $J(u)$. The choice will depend on the problem at hand: set of constraints, admissible controls etc.