Forums Technical Articles Developer Docs 中文区 UART Decoder Module Database Models Quotes & Orders EN · 中文 · 日本語 · DE · ES

Using an LRF22VB as a downward rangefinder with ArduPilot or PX4: native driver or MAVLink DISTANCE_SENSOR?

Viewed 0

Frequently asked by integrators; answered by ERDI Engineering.

I want an LRF22VB as a downward-facing rangefinder for altitude hold on a small multicopter running ArduPilot (PX4 is also an option). Can I plug it into a serial port and select a rangefinder driver? Which pins, baud rate and units do I need to care about?

1 Answers

We do not claim native support in either stack, and a driver that accepts the frame but misreads the distance field is worse than no driver. Native drivers work only when frame layout, baud rate and timing match one of the shipped protocols; check the driver source first (ArduPilot: https://ardupilot.org/copter/docs/common-rangefinder-landingpage.html, PX4: https://docs.px4.io/main/en/sensor/rangefinders). The LRF22VB streams 4-byte 5C lo hi chk frames at 460800 baud, and we do not claim it matches a shipped flight-stack driver, so do not report a successful bench test as "supported by PX4".

The pattern we recommend for a first integration is a companion computer:

  1. Read the module on a hardware UART (3.0-3.6 V supply, so power it from a 3.3 V rail, not from a 5 V pin), 460800 baud.
  2. Validate the frame: header 5C, checksum, and the out-of-range marker 20000.
  3. Convert millimetres to centimetres for MAVLink (the VB wire unit is millimetres, so divide by 10) and publish DISTANCE_SENSOR (message id 132) with min and max distance, current distance, orientation and your own covariance from logs.
# pymavlink sketch: raw is the 16-bit LRF22VB value in mm
def send(master, t_ms, raw):
    if raw == 20000:               # out of range marker
        return
    master.mav.distance_sensor_send(t_ms, 5, 2000, raw // 10,
                                    0, 1, 25, 0)   # laser, id 1, pitch 270 (down)

The module range is 0.05-20 m at 90 % reflectivity but only 0.05-10 m at 10 %, so set the flight stack's maximum from your real ground surface, not from the headline number, and remember the flight stack rejects values below its configured minimum. Frame rate can be set from 1 to 200 Hz (5A 0B 02 <divisor> <chk>; 10000 / (divisor + 1)). Do not share the UART with a second reader, bench-test with vibration and motors running, and record the raw log. The full checklist is in the flight-controller integration guide in the docs.

Sources:

ERDI Verified Answer — checked against the datasheet by ERDI Engineering.

ERDI Engineering Community is run by ERDI TECH LTD (Chengdu, China) · erdilrf.com · GitHub · Civil applications only · Questions about modules from any brand are welcome.