RPLidar A2 Setup on Linux
I purchased an RPLidar A2 for hobby use last year but didn’t have time to try it out until this recent break (I got a puppy and took a week off work to take care of it – now the downtime means hobby stuff).
Setup for this thing is not that easy. The quick start guide says to go to http://go.slamtec.com/rplidar/a2/download but I think that page no longer exists and you have to know to go to the downloads page and get the SDK from there.
Then once you get the SDK, you need to read the Manual to get build, drivers, and usage instructions. There’s no readme in the SDK itself.
I’m documenting stuff here for next time I try to set this up on another computer.
Installing the CP210x USB to UART Bridge Driver
The RPLidar comes with a little chip that converts USB to TTY, which is what the actual lidar unit uses (but you want
to connect with USB for convenience). That chip requires a driver that is only included in some versions of Linux. If you aren’t seeing a result for
ls /dev | grep ttyUSB then download it here from the SILabs website.
The installation goes as follows:
- Extract the tarball
make( your cp210x driver )
cp cp210x.ko /lib/modules/`uname -r`/kernel/drivers/usb/serial
insmod /lib/modules/`uname -r`/kernel/drivers/usb/serial/usbserial.ko
Running the Demos
There are two important demo programs. The first is
simple_grabber which grabs two rounds of laser data and prints a
histogram to your command line.
The second is more useful:
ultra_simple continuously fetches the RPLidar scan data and writes the output to the console.
This is probably more along the lines of what you’d do in production.
The C++ code behind these applications is open source and available in the sdk download at
/sdk/app/simple_grabber/main.cpp. The source is really readable.
OK now that I’ve seen my lidar actually take measurements, I’d like to collect some cool data about my room! I could manually write the software to do that, but what most people do is connect their RPLidar to ROS and use the libraries there to work with the 3d point data.
Hopefully I’ll get to that part soon!