Drone doesn’t avoid obstacles with distance sensors

Good afternoon everybody,

I am working with 4 Teraranger Evo Mini sensors pointing forward, backward, to the left and right; and Ardupilot Firmware, flying in LOITER mode.

The sensors work perfectly in the 4 orientations, measure with precision and gather good information. The problem comes when trying to set them up for obstacle avoidance , that the drone doesn’t stop when finding an obstacle at certain distance.

I leave here the parameters I configured, and hope that anyone know a solution:

Avoidance Parameters:

  • AVOID_BEHAVE = 1
  • AVOID_DIST_MAX = 2
  • AVOID_ENABLE = 7
  • AVOID_MARGIN = 2

Proximity Sensor parameters:

  • PRX_TYPE = 4
  • PRX_IGN_ANG1 = 45
  • PRX_IGN_ANG2 = 135
  • PRX_IGN_ANG3 = 225
  • PRX_IGN_ANG4 = 315
  • PRX_IGN_WID1 = 45
  • PRX_IGN_WID2 = 45
  • PRX_IGN_WID3 = 45
  • PRX_IGN_WID4 = 45

I even set up the obstacle avoidance for the RC controller:

  • RC8_OPTION = 40
  • RC8_MIN = 982
  • RC8_MAX = 2005
  • RC8_TRIM = 982

Hi @Nacho.
We need a log before anything can be said. Can you send a .bin file of whenever you flew this setup?
Additionally: What version of ArduCopter are you running?
Also, those PRX_IGN/WID params are not used for RangeFinders (as far as I can recall). We only use them for the 360 lidars where the scanner might face obstructions.

Lastly, why is RC8_TRIM set to 982? I am not sure, but would that turn on avoidance properly?
The channel needs to be “high” for proximity avoidance to kick in -> i.e: PWM >1800us

I think we send a text message to the GCS when proximity is enabled by the user, did you see that when you flip RC8 to high?

We need a log before anything can be said. Can you send a .bin file of whenever you flew this setup?

Neither I can’t find the right log right now (there are more than 305) nor fly the drone, so I will try again later.

Additionally: What version of ArduCopter are you running?

I’m running ArduCopter V4.0.7

Also, those PRX_IGN/WID params are not used for RangeFinders (as far as I can recall). We only use them for the 360 lidars where the scanner might face obstructions.

Now because I changed PRX_TYPE = 2 (Mavlink, so it reads from DISTANCE_SENSOR message), there’s no need to avoid those angles, I just receive in the 4 directions I set up.

Lastly, why is RC8_TRIM set to 982? I am not sure, but would that turn on avoidance properly? The channel needs to be “high” for proximity avoidance to kick in ->
i.e: PWM >1800us

It works anyway, just the minimum and neutral position are OFF (982) and the max is ON (2005).

I think we send a text message to the GCS when proximity is enabled by the user, did you see that when you flip RC8 to high?

Yes, when I trigger it, the message ch8in becomes 2005.


Now I get a message of “BAD PROXIMITY” but the measures of the sensors are very accurate. The drone started avoiding the obstacles, but I stopped to charge the batteries, and when I connected it again, the obstacle avoidance wasn’t working.

have also two parameters:

  • SERIAL4_PROTOCOL = 9 (Rangefinder)

  • SERIAL4_BAUD = 57 (As telemetry baudrate)

And I changed the following:

  • AVOID_ENABLE = 2 (Only with proximity sensor)

  • PRX_TYPE = 2 (Mavlink, to read from DISTANCE_SENSOR messages)

These last two changes made the Obstacle Avoidance work some time, later it stopped.