Collision avoidance via DISTANCE_SENSOR messages

I’m trying to connect multiple distance sensors of type GY-US42v2 to a CubeOrange with Ardupilot 4.3.7. My ultimate goal is to mount them around my drone and perform collision avoidance in multiple directions in guided mode.
My setup so far is documented in this thread in the hardware forum.

To sum it up, I’m currently sending Mavlink messages of type DISTANCE_SENSOR via serial connection to the FC, where I set the following parameters:
params.param (18.2 KB)
with the interesting parameters being:

  • SERIAL1_TYPE = 2
  • SERIAL1_BAUD = 115
  • RNGFND1_TYPE = 10
  • RNGFND1_ADDR = 1
  • PRX1_TYPE = 2

The setup works for 1 sensor, I can see a range being shown in the Proximity view (STRG-F and button “Proximity”). Now I’d like to extend this setup to 8 sensors, which all send DISTANCE_SENSOR messages. Everything so far led to several questions:

  • What is the difference between the RNGFNDX_ and the PRXX_ parameters? Do I even need them both?
  • I only have PRX1_, PRX2_ and PRX3_, how do I get more? I tried setting AVOID_ENABLE from “3” to “8” (and rebooted) to no avail.
  • How are the incoming DISTANCE_SENSOR messages associated with the corresponding sensor that is configured on Ardupilot’s side? The RNGFNDX_ parameters have a parameter named RNGFNDX_ADDR, is this supposed to match the id field in the DISTANCE_SENSOR message? The PRXX_ parameters don’t seem to have any kind of identification.
  • Is the Proximity window even a viable indicator for working collision avoidance sensors, or am I using it incorrectly? Does it only show proximity sensors and not rangefinders?

Because your just using it as a proximity sensor you dont need to see the rangefinders as individual sensors. since your not tying to see depth or altitude you can just ignore the rangefinder settings and set PRX1 to mavlink and it will display all mavlink rangefinders with orientation 0-7 on the proximity display.

so you dont need to set a proximity device for each sonar but each group.

you only need to set it as a rangefinder to see the values from above and below on mission planner.

Yes, that did it, I just tried it successfully with 2 sensors. Thanks a lot.

Note that you seemingly can’t have both. With PRX1_TYPE set to “Mavlink” and Mavlink rangefinders configured via RNGFNDX_TYPE, it didn’t work for me.

Summing everything up:

  • SERIAL1_TYPE = 2
  • SERIAL1_BAUD = 115 (or whatever serial speed you set in your Arduino code)
  • RNGFNDX_TYPE = 0 (X being a hex number from 1 to A, I think)
  • PRX1_TYPE = 2

And about my questions:

  1. According to the first note on the proximity landing page, rangefinders are one dimensional sensors that return data in exactly one direction and proximity sensors return data in multiple directions. In my setup, Ardupilot sees only one one device (the Arduino) that delivers range data for several directions via serial connection, so I had to configure it as a proximity sensor (PRX1_TYPE). If you directly connect the sensors to the FC, you would configure each one as rangefinder(RNGFNDX_TYPE).
  2. Each proximity sensor can cover every direction in one plane, so one is enough for me (and most others).
  3. They aren’t, as said under 1., I have only one proximity sensor device that works in multiple directions. The differentiation of the messages is done via the different orientation settings (every sensor sends it’s orientation with the DISTANCE_SENSOR message).
  4. The window is a working test for proximity sensors, rangefinders i didn’t test.
1 Like