Return to Robotics Tutorials

Adding inexpensive LIDAR to your Robot - Neato XV11!

One of the most important operations for a robot is to sense the surroundings, whether to avoid an obstacle, locate an object or map the environment (SLAM). Many robots use Ultrasonic or InfraRed proximity sensing, but the LIDAR (LIght Detection And Ranging) has become very popular due to its speed and accuracy. While scanning LIDAR tends to be incredibly expensive, a few recent options are cheap enough (<$100) for even hobby robots!

Scanning LIDAR mapping

Neato XV11 LIDAR Plot
Scanning LIDAR plot of room

The image on the left was captured from a scanning LIDAR sensor from inside a room. In this example, the LASER sensor is spinning about 5 times a second, measuring the distance to the nearest surface from each angle outward from the robot (shown as a white dot in the middle). As this sensor generates a distance measurement for every angle of rotation, it produces 360 distance measurements per revolution. From these measurements, we can then convert the data into a set of points on surfaces surrounding the robot.

With enough data points, the set of coordinates (point cloud) can be used to identify the location and angle of walls, obstacles and doorways from the perspective of the robot. This mapping information can then assist in the robot's navigation, positioning or obstacle avoidance algorithms.

In this particular example, I used a scanning LIDAR setup that cost less than $100. I then wrote a C program to read the sensor's serial UART interface, convert the coordinates from polar to rectangular and plot the resulting data points in real-time. Finally, I applied a color coding to the point cloud according to the measurement quality (signal strength) reported by the sensor for each distance sample. Walls close to the robot are red (high quality) while distant points are blue (lower quality). At the bottom of the image, we can see the open door has revealed a wall on the far side of a corridor.

Neato XV-11 LIDAR

Neato XV-11 LIDAR photo
Neato XV-11 LIDAR

One of the cheapest scanning LIDAR sensors appears to be the Neato XV-11. Unlike other general-purpose LIDAR units, the Neato sensor is actually built-in to the Neato XV-11 robotic vacuum cleaner! Unlike other vacuums (such as Roomba) that wander randomly across your floor, the Neato uses its LIDAR sensor to map the room and plan a suitable route for vacuuming.

There are a number of people selling refurbished LIDAR sensor assemblies for $100 on eBay, which makes it the cheapest option if you don't mind integrating a used / refurbished sensor into your robot.

In the image at the right, one can see the spinning plastic turret with two holes: the leftmost contains the LASER diode emitter while the rightmost hole contains a linear imaging element.

Below the turret you can see a DC motor on the right hand side that is used to spin the top assembly. Note that the motor is typically powered by a PWM signal that allows rotational speed control. Some people use a low duty-cycle PWM at 12v to do this (with a closed-loop PID control circuit), but empirically it seems like a constant 3.3v source is sufficient to maintain ~240rpm.

Connecting up the Neato XV-11

Neato XV-11 LIDAR pinout
Neato XV-11 LIDAR Pinout

The Neato XV-11 provides two cable connections: a 2-pin motor power connector and a 4-pin sensor connector. These connectors are 2.0mm pitch JST headers, which makes them unsuitable for direct attachment to a solderless breadboard. Therefore, it is more convenient to solder breadboard wires to a 2.0mm JST plug (or cut the original wires and add the 2.54mm / 0.1" connectors).

The simplest configuration to test the Neato XV-11 is to interface with the sensor using a FTDI232 UART-to-USB module and power the motor with a regulated 3.3v source.

Configuring a PuTTY terminal to 115200 bps / 8N1 and the correct COM port (identified in Device Manager within Windows), one will see the boot-up screen after powering on the sensor:

Neato Boot console
Neato Boot Console

From here, one can issue a number of diagnostic commands (type "help" to see a list of available commands).

Testing the Neato XV-11

Note that the serial console doesn't report any sensor data until the motor is spinning. If you spin the assembly by hand a few times, you should see text indicating Spin...3 ESCs or BREAK to abort... followed by binary data that will appear as gibberish in a text terminal.

My first attempt at reverse engineering the output was done by capturing the PuTTY session (binary data) and examining it in a hex editor. From there, it became evident that the sensor data was delivered in 22 byte packets starting with an 0xF0 marker and encoded angle indication.

Next step was to write a simple C program that listened to the serial port (via the FTDI232 UART-to-USB bridge) and synchronize to the sensor data packets. Finding a few references online to the Neato packet format meant that it was a simple matter to decode the sensor data.

The first attempt at visualizing the data was through a console interface reporting a real-time histogram of depth information:

Neato Histogram
LIDAR Depth Histogram

Although it is very hard to visualize the depth map in a simple ASCII histogram, it did reveal a few things about the Neato XV-11 LIDAR:

  • The distance measurements (in mm) were extremely stable. Fluctuations were generally < 1cm.
  • Measurements directed towards an LCD computer monitor were marked as invalid (assumed to be due to sensitivity to InfraRed). I anticipate operation outdoors with direct sunlight may give similar results.
  • Measurements out of range (ie. <15cm or >6?m) were marked as invalid rather than aliasing to a valid distance. This is a major improvement over my testing with the Sharp IR sensors. With the Sharp sensors, measurements too close could begin to appear as more distant positions.

Having confidence in the data decode, I then wrote a simple C program (in Visual C++) to visualize the distance point cloud in real-time. The result was more successful than I had expected for such an inexpensive sensor -- I was immediately rewarded with a detailed representation of the surrounding rooms and with reasonably stable measurements:

Neato XV11 LIDAR Plot Neato XV11 LIDAR Plot
LIDAR Room Plots with Neato XV-11

Rendering rays eminating outwards from the contour points makes it easier to distinguish between empty space and obscured space (ie. behind walls, etc.):

Neato XV11 LIDAR Plot
LIDAR Room Plots with contour rays

Next steps

  • Attempt simplification of the point data into robot collision decisions (ie. obstruction ahead, to left or to right) similar to what is currently achieved with the Sharp IR sensors on C2Bot
  • Remote transmission of LIDAR data from robot to Zigbee robot telemetry controller's screen
  • Initial attempts at mapping algorithms (after odometry is integrated) / SLAM

Alternatives to the Neato XV-11 LIDAR

There are a few other low-cost ranging sensors to consider, most of these also use triangulation to estimate distane, as opposed to real time-of-flight measurement.

  • PulsedLight LIDAR Lite v3 - $149 (not available yet). No scanning.
  • Slamtec RPLIDAR A2 - $449
  • Scanse Sweep - $255 (pre-order)

Background Info

LASER distance measurement with LIDAR

In general, LIDAR devices emit a pulse of LASER light and then determine how long it takes for the beam to reflect back to the sensor. Precise timing logic measures the total time and converts this to distances (by multiplying by the speed of light). In reality, most LIDAR sensors don't use this expensive timing circuitry and instead use phase shift or triangulation to estimate distance. These alternate techniques may not have the same capabilities as direct time-of-flight (TOF) measurement, but they can often be good enough for many robot applications.

The most basic LASER distance measurement devices include a stationary LASER emitter and receiver, providing a measurement of distance in a single direction. This may be fine for certain applications, but most others require a 2D LIDAR measurement, which typically captures distance across a range of headings on a single plane (eg. horizontally or vertically).

To create a 2D LIDAR measurement, a scanning LIDAR configuration is used. These often include a spinning mirror that reflects the LASER light across a range of headings. Another approach involves a rotating assembly that contains the LASER emitter / receiver pair inside the spinning element. Rotating the emitter and sensor has the disadvantage that the sensor data needs to be passed across the rotating boundary (usually by way of a slip-ring). In 2016, Quanergy announced promising new technology that implements a solid-state LIDAR sensor (no moving parts).


Reader's Comments:

Please leave your comments or suggestions below!
2020-05-14Iman Nandi
 Could I get a copy of this code to test to my emaiil?
 hi; First of all congratulations about your lidar scan result. I have the same Neato XV-11 lidar and i have a few trial on it with raspberry pi but i can't get any graphical result from rViz.
Can you share about your C based windows program i think that will be very helpful for my process. Thanks in advance for your interest.

How did you reverse engineering the output? I am getting something(RRR, PPP, numbers, and etc) but I am not sure how to interpret this. Also, how do you know the sensor data was delivered in 22 byte packets? I can record a video of my screen, send it to you through email so you can see what I am getting.

I am also planning on using this sensor for a deep learning project, any chance you could also send me a link to the git once its created?
 can you share the vc++ code
 Hi Gopal!

The program output shown here was generated by a quick program I wrote in Visual C++ (under Windows) using SFML for graphics rendering. I could probably clean up the code and post it to GitHub. I'll send you an email once I have some code posted. Thanks for your interest!


Leave a comment or suggestion for this page:

(Never Shown - Optional)