YDLIDAR X2 - ROS review and Cartographer setup
This month I received a sample X2 LiDAR from YDLIDAR. In this blog post I’m documenting my experience using it and using it for SLAM using ROS and Google Cartographer.
|Range resolution||2% of distance|
General feel and comparison to YDLIDAR X4
X2, similarly to X4, is a 360° LiDAR that is belt driven by a small motor. Structurally the LiDAR is very similar to the X4 that I reviewed back in January, however the footprint is a bit smaller as you can see in the photo below.
Compared to X4 the X2 has a lower scanning range (8m compared to 10m) and slightly lower resolution (2% for X2 compared to 1% for X4). The default scan rate of X2 7Hz, however it can be adjusted using PWM signal.
What I especially like about the X2 is the upgraded interface box that is now enclosed in plastic and the data port is now a USB C port (there is still an extra micro USB port for power, which I didn’t need to use so far).
When testing the LiDAR I was using the official ydlidar package (for early adopters make sure you are on s2 branch for X2).
The package I tested with is the same as I used in my review of X4 so instead of focusing on it again let’s jump to SLAM setup and making it work with Cartographer.
YDLIDAR X2 Cartographer setup
Cartographer “is a system that provides real-time simultaneous localization and mapping (SLAM) in 2D and 3D across multiple platforms and sensor configurations”. I found Cartographer to be a bit more resilient when working with LiDARs that have a relatively slow update rate. In the video below you can see how did cartographer work with X2 with the setup that I used:
Close to 10th second of the video you can see at the top that by mistake I pointed the LiDAR at the ceiling, however after tilting it back and keeping it steady Cartographer corrected it and localized properly.
It’s quite likely that the setup can be tuned to work even better. If you would like to start where I left off here is the Cartographer lua script that I used:
You can view the full project source code on GitHub. If you would like to check the data yourself I recorded a bag file of a run you saw in the video above. It is located in a bags file in the root of the repository.
Final thoughts and further tests
X2 is a perfect LiDAR for the price, especially for hobby or classroom use. I expect that this LiDAR should work perfectly for slowly moving (< 1 m/s) robots as an only source of odometry information. For anything requiring to move faster quite likely additional sources of odometry will be required.
In the future I would love to see an update to the ros package that would add a dynamic reconfigure support and maybe even add support for nodelets.
Unfortunately I didn’t get to test the LiDAR in full sunlight (we didn’t get much of it since I started testing the unit). Sometimes I saw some noise in the scans in the direction of windows but unfortunately I don’t have any hard data at this stage. As soon as I get a chance to tet the LiDAR in harsh outside environment I’ll update this blog post.
- YDLIDAR ROS repository: https://github.com/YDLIDAR/ydlidar/
- YDLIDAR datasheets: http://www.ydlidar.com/download
- YDLIDAR X2 on Amazon: https://www.amazon.com/dp/B07S35L2NG
- Cartographer ROS documentation: https://google-cartographer-ros.readthedocs.io/en/latest/