Hi @rishi, thanks for the ping. I’ve written two demos for your reference and committed them to the following branch: feature/rplidar_tool. These scripts use the rplidar-roboticia library to interface with the 2D Lidar sensor. They are:
stretch_rplidar_job.py - Demonstrates the API used to interface with the sensor. Additionally, this script can be used to save Lidar scans into a dataset. This makes it easier to develop algorithms offline.
stretch_rplidar_mapping.py - Demonstrates how to generate grid maps from Lidar scans (live or from a saved dataset). This script utilizes PythonRobotics’ lidar_to_grid_map module to generate the grid maps.
At the moment, the mapping script will only accept previously captured Lidar scans. There seems to be a bug with how Matplotlib visualizes the scans captured by the RPLidar library (I can provide more details if interested). I will push an update when resolved.
To make the demos accessible, we plan to ship them with Stretch_body. Until then, you may try them out using the following setup steps:
git clone https://github.com/hello-robot/stretch_body.git --branch feature/rplidar_tool
curl https://raw.githubusercontent.com/AtsushiSakai/PythonRobotics/master/Mapping/lidar_to_grid_map/lidar_to_grid_map.py -o lidar_to_grid_map.py
Next, you may run the demos and visualize the grid maps (with a monitor plugged into the robot) using:
python stretch_rplidar_jog.py --read_measurements ~/saved_scans.pickle
[Ctrl-C to close the previous script and save the dataset]
python stretch_rplidar_mapping.py --lidar_file ~/saved_scans.pickle
The grid maps will be visualized in a Matplotlib window, showing the open space as seen by the robot’s Lidar sensor. Generally, the next step in mapping is to use an algorithm called Iterative Closest Point (ICP) to align subsequent scans onto previous ones as the robot moves around. This yields a cloud of points that can be turned into a grid map that builds up as the robot moves. With your map, you can use any common grid map based planning algorithm to plan paths around obstacles in the environment.
Let me know if you have any questions, or come across any issues running these demos.