Skip to content

Access raw data from Garmin LIDAR-Lite v4 or Slamtec RPLidar Scanner in Python

License

Notifications You must be signed in to change notification settings

jamescoledesign/lidar-py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LIDAR Scanner Control and Data Visualization in Python

The examples here were created as a class project to enable access to raw data generated by LIDAR modules connected to serial ports via microcontrollers. The program can access any raw data printed to the serial monitor, but is currently designed to parse LIDAR data from the Garmin LIDAR-Lite v4 and Slamtec RPLIDAR A1 devices.

Once data has been collected or imported, the program will render a basic point cloud plot or an interactive plot.

Read more about this project here.

Tested LIDAR modules

  1. Garmin LIDAR-Lite v4
  2. Slamtec RPLIDAR A1

Instructions

There are two demo files available, one for each LIDAR module tested. Data from previous scans can be imported via CSV files. After importing packages, simply skip ahead to 2b. Import data to create plots from the imported data.

1. Install dependencies and import packages

  • pySerial: pip install pyserial
  • pandas: pip install pandas
  • Matplotlib: pip install matplotlib
  • numpy: pip install numpy
  • PyVista: pip install pyvista
  • PyVistaQt: pip install pyvistaqt

If using RP Lidar A1

  • rplidar: pip install rplidar-roboticia

2. Run scan (a) or import data (b)

2a. Run scan

  • Get serial port information
  • Declare ports
  • Scan
  • Clean data
  • Export data (optional)

2b. Import data

3. Plot point cloud using PyVista

  • Create basic plot
  • Create interactive plot

Example plots:



C++ files

Note: The C++ files are not required to run this program. They simply demonstrate how information printed to the Serial console from a C++ program can be accessed via Python.

Garmin LIDAR-Lite v4

The files in cpp/garmin-lidar can be used to send lidar distance measurements and servo positions from the Garmin LIDAR-Lite v4 attached to two servos.

C++ libraries used

  • Wire
    • Enables I2C communication for the Arduino UNO R4 WiFi
  • SparkFun_LIDARLitev4_Arduino_Library
    • Example1_GetDistance.ino in the Examples folder of this library only required slight changes to work for this project.
  • Servo
    • Control behavior of attached servos. This is a modified version of the Sweep example file from the Servo library.

Slamtec RPLIDAR A1

The files in cpp/rp-lidar control a single servo. Data from the RP Lidar A1 can be accessed in Python by installling and importing RPLidar.

C++ libraries used

  • Servo
    • Control behavior of attached servos. This is a modified version of the Sweep example file from the Servo library.
  • Async_Operations
    • Continuously send servo position. Asynchronously send an updated position after a time delay.

Future work

  • Make a generalized function to collect any data printed to the serial ports.
  • Send user preferences to the microcontroller from Python. Currently this is being done when activating the Garmin device to run a scan.
  • Examine the function for converting Cartesian coordinates to spherical coordinates. There appear to be issues when using this method to create point clouds using the RP Lidar.
  • Adjust the rate of point collection to create higher resolution point clouds.

Code references

About

Access raw data from Garmin LIDAR-Lite v4 or Slamtec RPLidar Scanner in Python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published