SkoltechRobotics / rplidar

Python module for RPLidar A1 and A2 rangefinder scanners
MIT License
185 stars 126 forks source link

Incorrect descriptor starting bytes #34

Open Mytre opened 4 years ago

Mytre commented 4 years ago

Hello, i am using an A3 lidar, I already changed the rplidar.py baudrate , now I am getting errors in rplidar line 211: dsize, is _single, dtype = self._read_descriptor()

and in line 189 in _read_descriptor raise RPLidarException('Incorrect descriptor starting bytes') rplidar.RPLidarException: Incorrect descriptor starting bytes

anyone has any idea how to fix this?

gzchenjiajun commented 4 years ago

same problem

claymaks commented 4 years ago

I was having this same problem when I stopped my script without properly closing my serial connection/disconnecting from the lidar. I solved it by catching any RPLidarException and then executing

lidar.stop_motor()
lidar.stop()
lidar.disconnect()
lidar = RPLidar(port)

Not all of these lines may be necessary, but in general, I found disconnecting and reconnecting solved my problem.

bsautner commented 2 years ago

I can confirm the above - happens when you don't have a clean shutdown - catch the error and restart the device:

def collect_data(client):
    try:
        lidar = RPLidar(None, PORT_NAME)
        for scan in lidar.iter_scans():
            post(client, scan)
    except RPLidarException:
        lidar.stop()
        lidar.disconnect()
        collect_data(client)