I’ve been struggling with obstace avoidance for a while now. I think I finally have a nearly workable solution using circular exclusion fences around trees and other fixed obstacles. I did try a cheap Lidar unit, but I was very unhappy with performance (and setup, to be honest – ArduPilot does not document the various parameters very well). Perhaps I’ll revisit with a 360 Lidar at some point, but geofencing works for now!
If you struggle like I did, getting geofences to properly upload from Mission Planner, be sure MAVLink 2 is enabled. My telemetry antenna is connected to serial port 1, so I set SERIAL1_PROTOCOL=2.