Trajectory Optimization for Underwater Vehicles in Time-Varying Ocean Flows