Problem of Avoidance in Loiter mode, but not in Alt Mode

Hi Everybody,

I’m new here and working on ardupilot with a PixHawk since 6 months. Really great firmware !
Now I have a problem…

I made a drone with a “special” configuration :slightly_smiling_face:
I have an arduino with some HC-SR04 connected, sending data to a Raspberry Pi (running pyMavlink) and sending sensors data to my PixHawk.
My drone avoids well in alt mode, but not in loiter mode. It seems that it doesn’t take in consideration the values of the sensors (but when I release the sticks the drone comes back to the landing position => maybe because of my optical flow ?). When I take a look at Mission Planner, the PixHawk sees the proximity sensors values, but when flying it does not avoid anything… except in alt mode (and it works great).

Any idea of what is wrong ? I saw in Github that the loiter mode doesn’t include these lines (included in Alt mode) :
#if AC_AVOID_ENABLED == ENABLED
// apply avoidance
copter.avoid.adjust_roll_pitch(target_roll, target_pitch, copter.aparm.angle_max);”

Does it mean that the loiter mode cannot work with the proximity sensors ?

I tried before to send data directly from my arduino to the pixhawk (with serial and the help of this great article : https://diydrones.com/profiles/blogs/avoidance-experiments-with-the-poc-and-benewake-tfmin), and same thing, great avoidance in alt mode but no avoidance in loiter mode…

Thank you for your help !

Hi there,

Any idea of what’s wrong? Any help would be greatly appreciate :slight_smile: