Obstacle avoidance in Auto mode (mission)

You could make a lua script so if anything is detected just switch to loiter mode to get the behavour you want.

You could use a modified version of my depth avoid script to do it, you want essentially the same behavour, stop before it gets into trouble.

Im only checking rangefinder:distance_cm_orient(25) for under the boat but you can add more orientations.