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
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.
- 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
- Get serial port information
- Declare ports
- Scan
- Clean data
- Export data (optional)
- Create basic plot
- Create interactive plot
Example plots:
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.
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.
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.
- 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.
- Charles Grassin: 3D Lidar Scanner
- Arduino Lidar Scanning & Java Rendering
- pySerial Docs
- PyVista Docs
- Garmin LIDAR-Lite v4 info
- Slamtec RPLIDAR A1 info
- Arduino to Processing
- Stream to CSV file
- Timestamp
- Timer
- Get index iteratively
- Iterate Pandas DF rows
- pyvistaqt
- Multiple lists to DataFrame
- Async in cpp
- Serial.read() from Arduino
- Access serial monitor (USB) using pySerial
- Spherical coordinate conversion
- Stopwatch
- Round a number