Skip to content

being24/YDLIDAR-SDM15_python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YDLIDAR-SDM15_python

A python3 library for the YDLidar SDM15.

Sample code

from SDM15 import SDM15, BaudRate

if __name__ == "__main__":
    lidar = SDM15("/dev/ttyUSB0", BaudRate.BAUD_460800) # change the port name to your own port

    version_info = lidar.obtain_version_info()
    print("get version info success")

    lidar.lidar_self_test()
    print("self test success")

    lidar.start_scan()

    while True:
        try:
            distance, intensity, disturb = lidar.get_distance()
            print(f"distance: {distance}, intensity: {intensity}, disturb: {disturb}")
        except KeyboardInterrupt:
            break

Tips

  • While scanning, the only thins you can do is to stop the scan. If you want to change the baud rate or other settings, you should stop the scan first.
  • This library automatically closes the serial port after calling stop_scan at program exit using atexit.
  • After changing the settings, we recommend you to reboot the sensor; the Baud rate setting will not be applied without rebooting, and other setting changes may cause unstable communication afterwards.
  • The lidar will not start scanning until you call the start_scan() method.
  • The development manual recommends to start SDM15 normally as follow:
    • first, get version info from the lidar
    • second, do self test and get the result
    • third, start scan
  • YdLidar's USB ADAPTER BOARD(which uses cp2102) only supports baud rate of 230400, 460800, 921600. So if you want to use other baud rate, you should use other USB TO UART module like FT231X.

About

A python library for the YDLidar SDM15

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages