Combining static and dynamic optimization approaches for path planning, with collision avoidance