andyblarblar / LD06

A Rust driver for the LD06 LiDAR
https://docs.rs/ld06/latest/ld06/index.html
5 stars 0 forks source link

Packets where 0x54 appear in the data are lost #3

Open nils-van-zuijlen opened 7 months ago

nils-van-zuijlen commented 7 months ago

By reading the code at lines https://github.com/andyblarblar/LD06/blob/69ceb9d973bc2e1cf0147e67304766581d8e8a1a/src/ld06_driver.rs#L125-135 I found that any packet that contains the start byte will be lost, and there can be a lot of these packets.

I implemented a python lib to parse these packets and the only way I found to reliably identify packets was to find contiguous bytes that start with the start codes and end with a valid CRC. If the CRC is invalid, only drop the first bytes up to the next start condition, even inside the "current" invalid packet.

My code is available at gitlab.univ-nantes.fr/equipe-de-robotique-lab-sciren/CDR_2024/-/blob/main/robot/code/robot/lidar/ld06.py with tests at gitlab.univ-nantes.fr/equipe-de-robotique-lab-sciren/CDR_2024/-/blob/main/robot/code/tests/lidar/test_ld06.py if you want to take a look.

nils-van-zuijlen commented 7 months ago

Also, the LD06-embed package is also affected because of its own way of start of packet detection.