An Optimal Control Approach to Flight Management Systems for Unmanned Aerial Vehicles