4141* Adafruit CircuitPython firmware for the supported boards:
4242 https://github.com/adafruit/circuitpython/releases
4343
44- Version 0.0.1 does NOT support CircutPython . Future versions will.
44+ Version 0.0.1 does NOT support CircuitPython . Future versions will.
4545"""
4646
47+ import struct
4748import sys
4849import time
49- import struct
50+ import warnings
5051
5152# pylint:disable=invalid-name,undefined-variable,global-variable-not-assigned
52- # pylint:disable=too-many-arguments
53+ # pylint:disable=too-many-arguments,raise-missing-from
5354
5455__version__ = "0.0.1-auto.0"
5556__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_RPLIDAR.git"
@@ -91,7 +92,7 @@ class RPLidarException(Exception):
9192
9293
9394def _process_scan (raw ):
94- """Processes input raw data and returns measurment data"""
95+ """Processes input raw data and returns measurement data"""
9596 new_scan = bool (raw [0 ] & 0b1 )
9697 inversed_new_scan = bool ((raw [0 ] >> 1 ) & 0b1 )
9798 quality = raw [0 ] >> 2
@@ -116,7 +117,7 @@ class RPLidar:
116117 baudrate = 115200 #: Baudrate for serial port
117118
118119 def __init__ (self , motor_pin , port , baudrate = 115200 , timeout = 1 , logging = False ):
119- """Initilize RPLidar object for communicating with the sensor.
120+ """Initialize RPLidar object for communicating with the sensor.
120121
121122 Parameters
122123
@@ -189,7 +190,7 @@ def set_pwm(self, pwm):
189190 self ._send_payload_cmd (SET_PWM_BYTE , payload )
190191
191192 def _control_motor (self , val ):
192- """Manipular the motor"""
193+ """Manipulate the motor"""
193194 if self .is_CP :
194195 self .motor_pin .value = val
195196 else :
@@ -313,42 +314,42 @@ def clear_input(self):
313314 """Clears input buffer by reading all available data"""
314315
315316 def stop (self ):
316- """Stops scanning process, disables laser diode and the measurment
317+ """Stops scanning process, disables laser diode and the measurement
317318 system, moves sensor to the idle state."""
318- self .log ("info" , "Stoping scanning" )
319+ self .log ("info" , "Stopping scanning" )
319320 self ._send_cmd (STOP_BYTE )
320321 time .sleep (0.001 )
321322 self .clear_input ()
322323
323324 def reset (self ):
324325 """Resets sensor core, reverting it to a similar state as it has
325326 just been powered up."""
326- self .log ("info" , "Reseting the sensor" )
327+ self .log ("info" , "Resetting the sensor" )
327328 self ._send_cmd (RESET_BYTE )
328329 time .sleep (0.002 )
329330
330- def iter_measurments (self , max_buf_meas = 500 ):
331- """Iterate over measurments . Note that consumer must be fast enough,
331+ def iter_measurements (self , max_buf_meas = 500 ):
332+ """Iterate over measurements . Note that consumer must be fast enough,
332333 otherwise data will be accumulated inside buffer and consumer will get
333- data with increaing lag.
334+ data with increasing lag.
334335
335336 Parameters
336337
337338 max_buf_meas : int
338- Maximum number of measurments to be stored inside the buffer. Once
339- numbe exceeds this limit buffer will be emptied out.
339+ Maximum number of measurements to be stored inside the buffer. Once
340+ number exceeds this limit buffer will be emptied out.
340341
341342 Yields
342343
343344 new_scan : bool
344- True if measurment belongs to a new scan
345+ True if measurement belongs to a new scan
345346 quality : int
346347 Reflected laser pulse strength
347348 angle : float
348- The measurment heading angle in degree unit [0, 360)
349+ The measurement heading angle in degree unit [0, 360)
349350 distance : float
350351 Measured object distance related to the sensor's rotation center.
351- In millimeter unit. Set to 0 when measurment is invalid.
352+ In millimeter unit. Set to 0 when measurement is invalid.
352353 """
353354 self .start_motor ()
354355 status , error_code = self .health
@@ -387,12 +388,21 @@ def iter_measurments(self, max_buf_meas=500):
387388 if data_in_buf > max_buf_meas * dsize :
388389 self .log (
389390 "warning" ,
390- "Too many measurments in the input buffer: %d/%d. "
391+ "Too many measurements in the input buffer: %d/%d. "
391392 "Clearing buffer..." % (data_in_buf // dsize , max_buf_meas ),
392393 )
393394 self ._serial_port .read (data_in_buf // dsize * dsize )
394395 yield _process_scan (raw )
395396
397+ def iter_measurments (self , max_buf_meas = 500 ):
398+ """For compatibility, this method wraps `iter_measurements`"""
399+ warnings .warn (
400+ "The method `iter_measurments` has been renamed "
401+ "`iter_measurements` to correct spelling" ,
402+ PendingDeprecationWarning ,
403+ )
404+ self .iter_measurements (max_buf_meas = max_buf_meas )
405+
396406 def iter_scans (self , max_buf_meas = 500 , min_len = 5 ):
397407 """Iterate over scans. Note that consumer must be fast enough,
398408 otherwise data will be accumulated inside buffer and consumer will get
@@ -401,20 +411,20 @@ def iter_scans(self, max_buf_meas=500, min_len=5):
401411 Parameters
402412
403413 max_buf_meas : int
404- Maximum number of measurments to be stored inside the buffer. Once
405- numbe exceeds this limit buffer will be emptied out.
414+ Maximum number of measurements to be stored inside the buffer. Once
415+ number exceeds this limit buffer will be emptied out.
406416 min_len : int
407- Minimum number of measurments in the scan for it to be yelded .
417+ Minimum number of measurements in the scan for it to be yielded .
408418
409419 Yields
410420
411421 scan : list
412- List of the measurments . Each measurment is tuple with following
422+ List of the measurements . Each measurement is tuple with following
413423 format: (quality, angle, distance). For values description please
414- refer to `iter_measurments ` method's documentation.
424+ refer to `iter_measurements ` method's documentation.
415425 """
416426 scan = []
417- iterator = self .iter_measurments (max_buf_meas )
427+ iterator = self .iter_measurements (max_buf_meas )
418428 for new_scan , quality , angle , distance in iterator :
419429 if new_scan :
420430 if len (scan ) > min_len :
0 commit comments