ardupilot icon indicating copy to clipboard operation
ardupilot copied to clipboard

AP_Proximity: add RPLidar S2 support

Open tatsuy opened this issue 3 weeks ago • 0 comments

This is a follow-up PR for #26835 which included the following changes:

  • RPLidar S2 support (originally contributed by @mirkix)
  • Removed memory copy for each measurement (by @mirkix)
  • Added Dense Express (capsulated) scan support for RPLidar S2 with checksum validation to reject corrupted packets
  • Added a SITL model for RPLidar S2
  • Extended the serial corruption simulator
  • Added a ProximitySensors autotest entry for rplidars2

I've tested #26835 and seen cases where the RPLidar S2 TX line becomes noisy or intermittent (e.g. a marginal connector contact). This produced corrupted serial frames, witch cause the driver to lose sync witch scan packets. To address this, I added checksum validation (Dense Express) to discard corrupted packet.

Settings

PRXx_TYPE 5 (RPLidarA2) SERIALx_PROTOCOL 11 (Lidar360) SERIALx_BAUD 1000

What I tested

  • SITL test Confirmed S2 (and A1/A2) work correctly in SITL: ./Tools/autotest/sim_vehicle.py --gdb --debug -v ArduCopter -A --serial5=sim:rplidars2 --speedup=1 -l 51.8752066,14.6487840,0,0 --map

  • Serial Corruption Testing set AP_SIM_SERIALDEVICE_CORRUPTION_ENABLED to 1 run SITL under Valgrind (-V) and confirmed no memory errors even under heavy corruption. (confirmed S2/A2) ./Tools/autotest/sim_vehicle.py --gdb --debug -v ArduCopter -A --serial5=sim:rplidars2 --speedup=1 -l 51.8752066,14.6487840,0,0 -V

  • HW Testing Manually wiggled the TX line on an S2 unit to inject real-world corruption. Confirmed that:

    • corrupted packets are discarded via checksum,
    • the driver stays synchronised,
    • descriptor parsing no longer gets stuck in repeated RESETs.

I also tested this with Rover at 50Hz loop rate using A2/S2. I only have A2/S2. so I didn't test A1/C1/S1.

tatsuy avatar Dec 05 '25 08:12 tatsuy