RPlidar S2 - Can’t get it to work reliably from Python programs

Dear all,

right now I have a hard time to operate my RPLidar S2 from Python. I tried two libs but they are not stable for one major reason I found out when I tried to write my own lib: The SLAMTEC protocol doesn’t give you any chance to sync again if a transmission error (loosing a byte or so) occurs, no safe sync marker.

I am not able to read a whole scan sweep w/o problems!

The SLAMTEC documentation on one hand seems to be outdated. For instance, nowhere I could find, that the S2 communicates with 1MBaud instead of the 115400 as set as default in all libs.

OTOH on https://github.com/Slamtec/rplidar_sdk they advertise a completely different (and new?) protocol. But that does not work at all.

What I wonder now is: Is there anyone operating an RPLidar S2 (on a Raspberry Pi) from Python? Which lib do you use? What’s your experiences? Any hints or pointers to additional, helpful dox?

Best regards
poseidon62

Hi, have you seen this adafruit document? Overview | Using the Slamtec RPLIDAR on a Raspberry Pi | Adafruit Learning System

1 Like

Tanks for the pointer, but the problems are the same here: After roughly 400 scans I get a RPLidarExcpetion( “Wrong body size”). If I try to proceed by issuing iter_scan() again, the software is not able to recover, the error persists. No surprise to me: When a byte is dropped, all the bytes to come are shifted by 1 byte and the software is not able to understand the data stream.

Now, I could do a reset, that stops the motor and then restarts it when issuing a iter_scan() again. But honestly: Stopping and starting the motor because a of a glitch in the transmission?

How do others do here?

Hi,

I had the same problem with python.
So I developped an c++ shared library, and I use it in my python script.
It’s working well.