Optimal Trajectory Tracking for an Autonomous UAV