Lidar Sweeper
Accurate range-finding (and obstacle avoidance) with a LidarLite or TF Mini Lidar.

Why?

Collision avoidance is critical for real-world outdoor robots. Detection systems such as parking sensors are a possible candidate, but have limited range, and may not detect small, soft (ie sound absorbing) or pathologically shaped objects well.

Professional lidar systems such as those used in autonomous cars are many thousands of dollars, whereas the Lidar Lite (at $US150) and Benewake's TF Mini Lidar (at $US40) are cheap alternatives, but they need sweepers to make them detect in multiple directions. Sweepers such as the scanse are promising, but very expensive, and probably delicate.

So what can the impoverished hobbyist do at home?

Sweeper V0 - pan and tilt

These pan/tilt stands are actually designed for cameras, but with bit of fiddling a lidar can be mounted instead.

There are issues with this method. Mainly, it is very hard to accurately work out the current direction of the lidar without some careful calibration.


Sweeper V1 - back and forward

The Sweeper V1 is just a LidarLite-V1 mounted on a stepper motor so it can swivel around. The Arduino repeatedly reads the lidar distance, sends the reading via serial port (USB actually) to the host, steps the motor by one position and repeats. If the reading fails (object too distant, object too black, looking into mirror etc) then the read call to the lidar seems to time-out, delaying the sweeper. Readings on the Lidar are from 1cm to 4000cm (up to 40m), and are sent as two-byte values.

Distance readings may need to be converted into Cartesian coordinates, depending on the logic of the navigator.

This is the easiest way to use the LidarLite for navigation - just mount the LidarLite so that it sweeps to left to right. To be useful in production it will need some way to synchronise. This could be a hard limit on the rotation, or could, in principle, synchronise to an object on the robot.

If this is used, eventually the continually twisting cables will make them break.

The CAD concept

 enlarge

Sweeper V2 - slip ring

A little more work and a slip ring can produce a more elegant solution - the lidar can do full rotations and proper scanning, which doesn't involve the continuous twisting of wires.


Sweeper V3 - bearing mount

With still more work, a bearing and a belt-drive can provide an elegant and robust solution. This can be mounted on an outdoor robot, and survive a minor collision. If the dome gets scratched, then it can be replaced for a few dollars (it is a 4 inch security camera dome from eBay).

The bearing here is a bicycle bearing, which is small and robust.


Note, the four wires going between the Nano and the LidarLite go through a slip ring.


Sweeper V4 - using a CNC

With a CNC, more things are possible - like printing your own gears.

A cheaper lidar also opens other possibilities - like scrapping the dome, and taking the risk of damaging and just replacing the (relative cheap) lidar in a collision.


Note, the four wires going between the Nano and the lidar go through a slip ring, but the RX wire is not actually connected to anything.


A preliminary test on a sheet of clear perspex (much cheaper than chomping through the lid of a $15 hobby box).


Arduino Nano in the foreground, the EasyDriver behind it. [Note this is a much thicker stepper motor than the one used in the final build].


And with the EasyDriver in the foreground. The BigEasyDriver is great for higher torque, but the smaller EasyDriver was great for this project.


Components - Buoy in the Bubble

Box Jaycar This case has an extra-high lid, and everything is actually mounted in the lid, not the base.
Stepper Motor Interweb / bottom drawer Salvaged from an old printer, but 17HS3430 (photographed) would work.
EasyDriver Sparkfun Stepper Motor Driver. The EasyDriver can run directly on 24V
Bearing EBay / bike shop A bicycle bearing is a good size for this. 'Press bearings' look like good candidates, but are trickier to work with.
Arduino Nano EBay Arduinos are better than Raspberry Pis at talking to 5V peripherals (like the EasyDriver), and doing repetitive grunt work to take the load of the Pi.
Slip Ring EBay Must have at least 4 wires for I2C connection to LidarLite.
Photo Interrupter EBay / Jaycar To synchronise the LidarLiteSweeper (ie to determine the direction).
Timing belt pulley EBay / AliExpress Goes on the shaft of the stepper motor.
Timing belt pulley EBay / AliExpress Big enough to fit the slip-ring into.
Timing Belt EBay / AliExpress Engages the two pulleys.

Components - CNC version

Box Jaycar 115x90x55 WxDxH, and flanges on the base for mounting.
Stepper Motor Interweb / bottom drawer Short Body Nema 17 Stepper Motor Bipolar 1A 13Ncm/18.4oz.in 42x42x20mm 4-wires.
This is thin stepper - rotating a turret doesn't require much torque.
EasyDriver Sparkfun Stepper Motor Driver. The EasyDriver can run directly on 24V
Bearing EBay / bike shop A bicycle bearing is a good size for this. 'Press bearings' look like good candidates, but are trickier to work with.
Arduino Nano EBay Arduinos are better than Raspberry Pis at talking to 5V peripherals (like the EasyDriver), and doing repetitive grunt work to take the load of the Pi.
Slip Ring EBay Must have at least 4 wires for I2C connection to LidarLite.
Photo Interrupter EBay / Jaycar To synchronise the LidarLiteSweeper (ie to determine the direction).
  CNC parts CNC Parts Various parts made with a CNC.

Synchronisation

A continuously rotating LidarLiteSweeper has an issue - working out the current orientation of the LidarLite. A little rotating arm passes through the photo interrupter on each revolution, allowing angle synchronisation for the rover.

Resolution, speed and coding philosophy

These stepper models have 200 steps per rotation (ie 1.8 degrees per step).

The spread of the lidar beam is about 2 degrees, so 1.8 degrees per step on the face of it seems a pretty good match. If it did one reading every 1.8 degrees, adjacent steps have a very small overlap, so even relatively small objects shouldn't be missed - especially the water taps in the yard, which can explode and cover equipment with salty (ie highly corrosive) bore water if struck by a heavy enough object (yes, it's happened).

While the LidarLite versions 2 and 3 claim to do 500 readings per second, the LidarLite V1 used in this project only does around 100 per second. With 200 steps per revolution, that's one complete scan every 2 seconds. This is good for a non-time-critical application like SLAM, but not so good for a collision avoidance on a fast rover.

The LidarLite sweeper code was written to move once per reading - and put up with the slow updates.

On the other hand, the TF Mini Lidar sweeper code was written to rotate at a constant rate, and return a value to the host whenever the lidar returned a reading. This will rotate as fast as required: better at avoiding large obstacles at higher speed, but risks miss small objects on the way (like water taps in the garden).

Software libraries

    The EasyDriver is rated up to 30V, so should be okay running off a 12V or 24V battery power supply. It draws between 35mA and 50mA at 24V.
    It is necessary to identify the wire pairs to the stepper motor. Green and Red seem to be a pair on the 17HS3430, but Black and Green seemed to be pairs on the slimmer motor. This should be checked with a multi-meter.

Software

The high level code on the Raspberry Pi is not available, but the lower level Arduino code is here:
    http://github.com/allegrobotics/arduino lidarlitesweeper: code to run on the Arduino to make the sweeper run, and report distances back to the host (Raspberry Pi). Of course this is a LidarLite V1 - the LidarLite V2 has some more smarts, and the program could probably be optimised a bit better.
    http://github.com/allegrobotics/arduino tfminilidarsweeper: code for the CNC (TF Mini Lidar) version.
(At the risk of stating the obvious there is no reason why the LidarLite could not be mounted on the later sweeper and vice versa), but the code would have to modified.)

The future

    If the aim is to provide obstacle avoidance, then they have to be compared to other solutions like parking sensors.
    In the real world, robots tilt, and a 40m range doesn't mean much if the robot tilts to the ground or the sky. Hence the obstacle avoidance logic is going to have to ignore long readings anyway (and not remember them either!) because they may be just sloped ground, or blue sky.
    Some of the parts could better be made with a 3-D printer.

Conclusion

Building the lidar sweeper was a great deal of work. From 2017-01, Kickstarter Scanse can supply something faster, but possibly more fragile for $US349. This is tempting, but perhaps not the best option for the experimental hobby roboticist trying to convince the wife that 'this really is a cheap hobby, Dear'.

Remember that robots should crash sometimes (if they aren't crashing, your are not stretching the software capability envelope hard hard enough!). If the lidar is made of self-fabricated parts, they can be replaced when parts break. If even one part of the Scanse breaks, how can it be repaired?

If you are serious about running the robot around (and crashing it) - it makes sense to build one yourself out of replaceable parts.

Leave a comment

Something I'm doing wrong? Solved my problems? Got a better idea? Got a similar problem?
Think I might have solved your problem? Ninety-nine problems, but your robot ain't one? Say so ..