SkoltechRobotics / rplidar

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

OSError: [Errno 5] Input/output error #16

Closed willnil closed 6 years ago

willnil commented 6 years ago

I am using the forked version from rplidar-roboticia @jjehl and run the example python code in my Raspberry Pi 3. I am new to python so I don't understand what cause this not working. The scanner motor is running but no scan datas are being read.

Traceback (most recent call last): File "/home/pi/example.py", line 10, in for i, scan in enumerate(lidar.iter_measures()): File "/usr/local/lib/python3.5/dist-packages/rplidar.py", line 397, in iter_measures raw = self._read_response(dsize) File "/usr/local/lib/python3.5/dist-packages/rplidar.py", line 223, in _read_response while self._serial.inWaiting() < dsize: File "/usr/lib/python3/dist-packages/serial/serialutil.py", line 572, in inWaiting return self.in_waiting File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 456, in in_waiting s = fcntl.ioctl(self.fd, TIOCINQ, TIOCM_zero_str) OSError: [Errno 5] Input/output error

Hope someone can help me on this. Thank you and sorry for my bad english.

jjehl commented 6 years ago

Your error means that the data are wrong. Be sure to use a rplidar A2 and check that the raw serial data are received correctly.

Please find here : https://github.com/Roboticia/Roboticia-drive/blob/master/software/roboticia_drive/sensor/lidar_a2.py an example about how to use the module.

willnil commented 6 years ago

Yes I am using rplidar A2. I ran the code in my laptop using python IDLE and I can get the scan datas. But when I run the code in the Raspbian OS of the Raspberry Pi 3, the errors above occured. So do you know how to receive the raw serial data correctly? Is this happened due to hardware (Raspberry Pi3) or software(pyserial, pushing out the read/write calls faster than the hardware can accept them?, I2C)

Thanks in advance.

jjehl commented 6 years ago

I ran on raspberry pi3 without problem. It is a sofware issue with your pi3. Be sure to set the correct usb to collect the data Try to colect serial from another source to check if it works (arduino is a good test) you can test with the roboticia OS derived from Raspbian because with this setup I am sure it works : http://www.roboticia.com/?page_id=258

Edit :
just to be sure : You have the usb card adaptater to collect the data from the lidar and to plug the lidar with usb on the RPI ?

willnil commented 6 years ago

Yes I am using the UART adapter from the RPlidar A2. The lidar is plugged with USB on RPi.

I just checked using the lsusb command in the raspbian terminal. The number(name) of usb changed once the lidar motor is started and thus the data cannot be read. I think this is the problem.

DIYalways commented 5 years ago

@willnil I meet the same problem when i use a UART TO USB cable receiving the serial data, and guess it is a bug of raspbian system. I wonder have you solve this problem?

willnil commented 5 years ago

@DIYalways hello the problem is caused by the insufficient power supply to the RPLidar. Once I connected the rplidar to a power port instead of the usb port of my laptop, that solved my problem.