Coder Social home page Coder Social logo

rplidar's People

Contributors

luckywang95 avatar newpavlov avatar ysshah avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rplidar's Issues

rplidar.stop() and rplidar.stop_motor() don't do anything

I am running an RPLidar A1M8 R5 model through the usb2serial board, into usb on a rasp pi 3b+. I have yet to be able to get any combination of commands involving stop() and stop_motor() to actually get the motor to stop sending/receiving, return to the "zero" point, and stop spinning. Has anyone else been successful in this?

The "get_info()" and "get_health()" functions work just fine. But the lidar scanner does not respond at all to the following stop commands....BUT, it DOES disconnect...

from rplidar import RPLidar

lidar = RPLidar('/dev/ttyUSB0')

lidar.stop()
lidar.stop_motor()
lidar.disconnect()

Incorrect descriptor starting bytes

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?

How to get one measurement at a time

Hi, this is a great repository! All the examples work out great for me. The only problem I have is when I call lidar.iter_scan(), it returns measurement continuously and the program just stucks there so that I can not do that tasks in the code. I am curious how can I get one measurement at a time from lidar so that I can do others tasks in a while loop.

Pseudo code for my desired program is:
while True:
1. Get raspberry pi v2 camera image
2. Get measurement from lidar (when I use lidar.iter_scan(), lidar starts returning scans continuously and the program gets stuck here forever)
3. Command robot to move

Appreciate your help.

Example doesn't work

Output is below. I am not sure this is a library problem or a problem initiating the scanner on my side.

{'hardware': 2, 'model': 40, 'firmware': (1, 20), 'serialnumber': u'DAD28AC1E8839EF2C0E69EF702652105'}
('Good', 0)
Traceback (most recent call last):
File "lidar.py", line 15, in
for i, scan in enumerate(lidar.iter_scans()):
File "/usr/local/lib/python2.7/dist-packages/rplidar.py", line 357, in iter_scans
for new_scan, quality, angle, distance in iterator:
File "/usr/local/lib/python2.7/dist-packages/rplidar.py", line 326, in iter_measurments
data_in_buf = self._serial_port.in_waiting
AttributeError: 'Serial' object has no attribute 'in_waiting'

Check compatability wih A2 sensor

It was reported that A2 sensor is not powering up motor while using this driver.

Seems that A2 does not react to DTR (Data Terminal Ready) signal, in case of A1 its not only used for initiating communication channel, but also to turn on motor. Evidently because motor stays turned off lidar can't collect data and returns nothing, which results in error.

Unfortunately I don't have A2 to test code on it, so help are welcomed!

OSError: [Errno 5] Input/output error

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.

Illegal Instruction (Core Dumped)

I came across an error while running RPLidar/examples/animate.py
It loaded for a few second then gave error message Illegal Instructions (core Dumped)
I am using a jetson nano (ubuntu)
Please help!

Wrong Body Size ERROR fix

I have A1 with Raspberrypi 3B, and I have encountered the Wrong Body Size, that is because there is a mistake in the rplidar.py file when defining the function start_motor() ,and stop_motor ().

in rplidar.py it is " self._serial_port.setDTR(False) " & "self.motor_running = False" for start_motor(),
and "self._serial_port.setDTR(True)" & "self.motor_running = True" for stop_motor(),
you need to opposite them.

/dev/ttyUSB0 not found

Hi, I'm running python3 on raspberry pi3b+.

The example code cant find the /dev/ttyUSB0 file.

I did the pip3 install as per the instructions. Is there any pre-requisite installs? Lidar is new out of the box.

lidar

string vs hex

\x is a string escape code in python which cause some confusion for example in the reset function.

b = '\x40'
print(b)

'@'

because \x40 is the ascii code for '@'

The pwm of the rplidar

I have a problem about pwm of rplidar.
I called lidar.set_pwm(250) and the rplidar exactly slow down.
But the motor speed up after I called lidar.iter_scan() to get data.
Could I acquire data with different frequency ?
Thanks!

problem with the scan data

when I run record_scans.py
and inside this for loop here :

try: print('Recording measurments... Press Crl+C to stop.') for scan in lidar.iter_scans(): data.append(np.array(scan)) except KeyboardInterrupt:

instead of data.append(np.array(scan)) line I print the "scan" object which is tuple that contain (quality,degree,distance)

but the problem is that I do not get 360 measurements in the scan, in each loop I get different number of measurement in a "scan" object, note that I did not change the lidar's position when it test it.

can you explain the cause or the solution to this problem urgently.

many thanks in advance

check bit not 1

raise RPLidarException('Check bit not equal to 1')
rplidar.RPLidarException: Check bit not equal to 1

Less read points than the C++ version

I've tried the python version on ubuntu and I keep getting about the third of the number of detected points resulted from the C++ version.
Using A1 Lidar
Thank you

Low amount of datapoints

When I run the scan method using the default pwm speed I only get around 120 scans back. Sometimes the gap is even 5 degrees. But when I lower the pwm speed and get back more samples, the speed between the samples is too low. Does anyone know how to fix this?

rplidar a2 motor pwm doesn't change

I modified the DEFAULT_MOTOR_PWM in 'rplidar.py' in the folder, but it did not change.

However, pwm did not change when I ran the examples.

How can I change the pwm?

means of "new_scan" and "quality" yields of iter_measures() method ?

1- "new_scan" is always False in txt file. What does that mean ?
2- What is the range of "quality" ? . What does it mean literally ? How can i improve it ?
"quality" always is one of either 0 or 15 for every scan.
Yields
------
new_scan : bool
True if measures belongs to a new scan
quality : int
Reflected laser pulse strength
angle : float
The measure heading angle in degree unit [0, 360)
distance : float
Measured object distance related to the sensor's rotation center.
In millimeter unit. Set to 0 when measure is invalid.
'''

Sometimes "check bit not equal to 1"

I ran the simple example described in "README.md" for several times. Sometimes it threw the exception "check bit not equal to 1". Sometimes it worked well. I don't know why...
Btw I use RPLidar A1 and connect it to a Raspberry Pi 3B.

animation is not working

Its been almost one month and i could not find a way to animate the graph which will show the surrounding. can you please tell me where should i do the modification?

`from rplidar import RPLidar, RPLidarException
import matplotlib.pyplot as plt
import matplotlib.animation as animation

lidar = RPLidar('/dev/ttyUSB0')

info = lidar.get_info()
print(info)

health = lidar.get_health()
print(health)

fig = plt.figure()

ax = fig.add_subplot(1,1,1, projection='polar')

def run(i):
angle = []
distance = []
for i, scan in enumerate(lidar.iter_scans()):

    for d in scan:  # d[0] : Quality of the measurement
        # if 0< d[1] <200:     #d[1] : Angle of the measurement
        #    print(d[2]/10)   #d[2] : Distance of the measurement '''
        angle.append(0.0174533 * d[1])
        distance.append(d[2])

    print('angle:', angle)
    ax.clear()
    ax.scatter(angle, distance, s=5)
    angle.clear()
    distance.clear()

ani = animation.FuncAnimation(fig, run, interval=50)
plt.show()

`

Implement missing commands

Currently following commands are not implemented:

  • FORCE_SCAN 0x21: this command is analogous to the SCAN command, but also returns debug information. Not fully documented.
  • EXPRESS_SCAN 0x82: will run scanner at the sampling rate as high as it can be. For A2 it should be 4 kHz.
  • GET_SAMPLERATE 0x59: returns sampling rates for SCAN and EXPRESS_SCAN commands
  • GET_ACC_BOARD_FLAG 0xFF: seems for accessing A2 motor control board. Not documented.

Descriptor Length Mismatch

Trying to get start out with the get info function. And I keep getting this error. I installed the driver for the cP210x and I have '/dev/tty.SLAB_USBtoUART' as my device which is what I found from the IORegistry and also in the Dev folder.

On a mac running the latest OS. Python and everything else is the latest version. I tried different baud rates but no luck. Any Ideas?

New scan flags mismatch

who can help fixing the following error: "New scan flags mismatch"

the logs are

request:
b'\xa5P'
descriptor:
b'\xa5Z\x14\x00\x00\x00\x04'
response:
b'\x06\x05\x01\x01\x02\x00\x01\x08\x01\x00\x02\x00\x00\x00\x00\x00\x04\x00\x01\t'
{'model': 6, 'firmware': (1, 5), 'hardware': 1, 'serialnumber': '02000108010002000000000004000109'}
request:
b'\xa5R'
descriptor:
b'\xa5Z\x03\x00\x00\x00\x06'
response:
b'\x00\x00\x00'
('Good', 0)
request:
b'\xa5R'
descriptor:
b'\xa5Z\x03\x00\x00\x00\x06'
response:
b'\x00\x00\x00'
request:
b'\xa5 '
descriptor:
b'\xa5Z\x05\x00\x00@\x81'
response:
b'\xaaU\x01\x01\x03'
response:
b'B\x03B\xabT'
response:
b'\x00\x00\xaaU\x00'
Traceback (most recent call last):
File "C:\Python\test_radar.py", line 17, in
for i, scan in enumerate(lidar.iter_scans(max_buf_meas=500, min_len=5)):
File "C:\Python\lib\site-packages\rplidar.py", line 365, in iter_scans
for new_scan, quality, angle, distance in iterator:
File "C:\Python\lib\site-packages\rplidar.py", line 341, in iter_measurments
yield _process_scan(raw)
File "C:\Python\lib\site-packages\rplidar.py", line 77, in _process_scan
raise RPLidarException('New scan flags mismatch')
rplidar.RPLidarException: New scan flags mismatch

Protocol

Lots of command raise issues. For example, get_info() after a scan is wrong. I will do some changes in the code to make it more reliable.
Are you interested I make a pull request (this means, you are always active on this project !) or do you prefer I improve only my fork ?

Wrong body size

i run the command: for meas in lidar.iter_measurments():
it's occur the

Traceback (most recent call last):
File "/home/nx/Desktop/rplidar/simple.py", line 15, in
for meas in lidar.iter_measurments():
File "/home/nx/.local/lib/python3.6/site-packages/rplidar.py", line 323, in iter_measurments
raw = self._read_response(dsize)
File "/home/nx/.local/lib/python3.6/site-packages/rplidar.py", line 199, in _read_response
raise RPLidarException('Wrong body size')
rplidar.RPLidarException: Wrong body size

i have read some solutions ,but it also occur sometimes . my pyserial version is 3.4.Thank you for your read

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.