SkoltechRobotics / rplidar

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

Roboticia changes #9

Closed jjehl closed 7 years ago

jjehl commented 7 years ago

Improve motor speed so It is possible to change the speed whenever you want (when motor is stopped or start) and keep the motor_speed in memory when you stop the motor.

Clean the reset message, to avoid parsing error.

Improve speed of clean_input with flush command

print the exact frame in the log (in hex)

jjehl commented 7 years ago

Separate a start() function to prepare for adding other scan method (Force and express). Give the possibility to iterate when you want without stopping the process scan. You can start/stop the motor and the laser separately and asking for measures when you want.

jjehl commented 7 years ago

Added the possibility to start the lidar in express scan mode.

jjehl commented 7 years ago

First result with express scan. I have an error in my doc. apparently the checksum for bytes 0 and 1 is 4 bits long and not 3 like it is written in the slamtec documentation ! In fact, not really an error but [3:0] means bit 1,2,3,4...

jjehl commented 7 years ago

The calculation for angle in express mode is really not easy. theta_k = w_i + (wi+_1 - w_i ) /32 *k - d_theta_k !!! At the moment I have weird result when parsing lidar express response

jjehl commented 7 years ago

After fighting a little with q3 format, express scan in now working. It is about 2 times faster than normal scan. Only tested on rplidara2 with raspberrypi and python 3.4

Usage :

lidar = RPLidar('/dev/ttyUSB0')
for i, scan in enumerate(lidar.iter_scans(scan_type='express')):
    print(len(scan))
    if i>30 : break 

I made some arrangements (probably possible to improve) to keep total backwards compatibility.

Just tell me if you plan to integrate the changes. If not, I'll register my own rplidar lib on pypi. Bye.