def test_simple_express_scan(): from pyrplidar import PyRPlidar import time lidar = PyRPlidar() lidar.connect(port="/dev/ttyUSB0", baudrate=115200, timeout=3) # Linux : "/dev/ttyUSB0" # MacOS : "/dev/cu.SLAB_USBtoUART" # Windows : "COM5" lidar.set_motor_pwm(500) time.sleep(2) scan_generator = lidar.start_scan_express(4) for count, scan in enumerate(scan_generator()): print(count, scan) if count == 20: break lidar.stop() lidar.set_motor_pwm(0) lidar.disconnect()
zaxiscorrection = math.radians(0.0) # #SET UP Z AXIS STEP SIZE AND STEPPER MOTOR RUN TIME (NO ANGLE SENSOR) zaxisanglestep = 2 * pi / zaxisindex # 360degrees divided by how many steps to take zaxisruntime = scanner_support_functions.getzaxisruntime( frequency, motorsteps, driveratio, m1, m2, zaxisindex, Nscancycles) timeperrev = zaxisruntime * zaxisindex # this is used to bring the scanner back home after scannning will use it to tune the stepper driver too # SET UP RPLIDAR lidar = PyRPlidar() lidar.connect(port="/dev/ttyUSB0", baudrate=115200, timeout=5) #USB also can set up uart pins if desired lidar.set_motor_pwm( 1000) # not needed for RPLIDAR A1 AS YOU CAN'T CHANGE THE SPEED. scan_generator = lidar.start_scan_express( 0, "raw" ) # raw if using typed data from scanner, not raw for data packed in string #0,1,2 is the scan type 0 is the express scan it gives 4000 measurements around generally the slower the better the accuracy appears to be time.sleep(2) # wait for rplidar to finish set up #open file for writing scan points as ascii filename = scanner_support_functions.getfilename() rootname = "_points_a.xyz" f = open(filename + rootname, 'a') #open point file for appending scan points xyz ascii data rootname = "_points_b.xyz" g = open(filename + rootname, 'a') #open point file for appending scan points xyz ascii data #scanning routine counter_scan_loops = 0 # scan loop