I plan to build a Rover to run on the roof, so I am worry about the rove will drop from the roof. I want to use Sonars HC-SR04, to detect the out of the roof situation, for example, the sonars is mounted toward the roof, if in the roof, the distance is 8cm, if out of the roof, the distance is larger than 10cm. then my rover will backward 20cm and turn right.
and if my rover is running with the mode of auto, and was set waypoint, but because the GPS precision, it may go out the roof and drop. so during the auto mode, how can I integrate the sonars to the ardupilot firmware to guide the rover backward 20cm, turn right and auto running along the waypoint again?
You would either need a lua script or a custom proximity sensor since you are trying to avoid when nothing is detected rather than when something is. I am planning on building something similar for avoiding kerbs.
Today I am studying the code of arduRover, I see the files of AR_WPNav_OA.cpp and AR_WPNav_OA.h. if OAPathPlanner used, for Dijkstras and BendyRuler algorithm, do nothing, and insert a customized simple pathfind algorithm, the simple pathfind algorithm is backward 20cm(this parametger can be calibrated, maybe 30cm, etc. according to the frame of rover), then trun right or turn left according to the waypoint setting, just as below simple picture. do you think it is feasible or not?
for the proximity sensor, i think sonar HC-SR04 or lidar VL53l1X can be used, for example, if the detected object distance > 10cm(can be calibrated), _oa_active set to true, if object distance <=8cm(can be calibrated). _oa_active set to false. default is false. how do you think?