This project describes step-by-step how you can build yourself a 360 degree Lidar for realtime outdoor mapping and position tracking on that map (aka ‘localization‘). This idea is also called ‘SLAM’ (simultaneous localization and mapping). We use inexpensive parts for this Lidar, so this is probably the cheapest 360 degree realtime Lidar you can build!
- 360 degree, realtime operation (important: world ground must be flat – for a 3D world, see section at the page bottom)
- sensor: LidarLight v2 (500 Hz measurements, approx. 1cm precision)
- field of view (horizontal): 360 degree
- range: 40m, indoor & outdoor
- rotation speed: 1-10 Hz (can be adjusted by potentiometer)
- diameter: 60 mm
- 3d printed chassis (so you need access to an 3d printer)
Note: all parts will be available as a DIY kit in this shop soon.
- Lidar Lite v2 sensor (alternatives: TeraBee TeraRanger One, LeddarTech Leddar One Sensing Module)
- Arduino Nano
- serial/USB converter
- DC motor (PMDC: 1.18mN*m, 24.4mm diameter, 2000 rpm, 2mm shaft, 5v, 170 mA load)
- ball-bearing (6807 ZZ 61807: inside diameter 35mm, outside diameter 47mm, height 7mm, steal sealing ZZ)
- slip ring (LPM-04A: outside dia 12.5mm, flange dia 24mm, length 15mm, 4 wires)
- rubber gasket (NBR70 – 70mm diameter, thickness 2mm)
- micro photo sensor (2mm opening, Omron EE-SX1108)
- mini screws (2mm diameter, 8mm length)
- 2 resistors (780 Ohm, 33K), 1 capacitor 680 uF
- base plate (3D print), layer height: 0.3 mm
- bearing base (3D print), layer height: 0.3 mm
- encoder ring (3D print), layer height: 0.1mm
The encoder ring has 15 pits, one pit is shorter and allows to detect zero position. Each pit triggers a voltage transition (0/1/0/1/0/1 etc.) in the light barrier, indicating the next 12 degree step. Using a timer, the degree steps in between (0-12 degree) can be computed.
- motor ring (3D print), layer height: 0.1mm
- disc base (3D print), layer height: 0.3mm
- disc lidar holder (3D print)
to be continued…(your ideas?)
- disc cover (3D print)
to be continued…(your ideas?)
1. Stick encoder ring and bearing base together:
3. Make sure that your bearing runs smoothly (can make one rotation after driving it with one finger). My bearing had too much grease inside, so I had to disassemble the bearing and remove the grease. Assemble bearing, motor and wheel. The motor should run clock-wise when connected to +5V and GND. If not, swap the connector wires.
6. Wire as shown below:
Note: Keep soldering time for the photomicrosensor short (max. 3 seconds), otherwise you risk to damage this sensitive component.
7. Test mechanics
Make sure that the disc can turn with a constant speed (and not erratic). If the speed is not constant, the lidar will not work properly. My 3d printed parts were not very precise, so I had to rasp all parts so they fit and and do not rub.
8. Flash Arduino code
Since we are using the serial/USB converter for flashing the Arduino, resetting the Arduino automatically will not work. Press ‘Upload’ in the Arduino IDE and then press the RESET button on the Arduino to initiate the code upload.
- LIDAR base parts (STL)
- LIDAR disc (STL)
- LIDAR OpenSCAD code
- Arduino Nano code
- LIDAR visualization and SLAM (mapping & localization) executable for Windows
- LIDAR SLAM code
10. Example usages:
- SLAM (Simultaneous Localization and Mapping). Using a SLAM algorithm (e.g. Hector SLAM), you can create maps (mapping) and estimate your position in those maps (localization).
usage slam.exe <dev> <mres> <mpx> <dpx> <hlev> <hdths> <haths> dev lidar device path (\\.\com3) mres map resolution meters (0.1) mpx map size pixels (600) dpx display pixel size (1.0) hlev hectorslam res levels (3) hdths hectorslam distance threshold (0.5) haths hectorslam angle threshold (0.9) example indoor: slam.exe \\.\com3 0.1 200 3 4 0 0 example outdoor: slam.exe \\.\com3 0.1 600 5 4 0 0
11. DIY 3D Lidar
Could this Lidar work in a 3D world (with sloped ground)? Well, by operating the 2D lidar in a vertical orientation. Then we get a 2D stripe of the world (including the current position on that 2D stripe) that we could use for mapping and localization – A compass would help us to estimate the orientation of new stripes (blue stripe).
For a realtime test I’m using a 2D LeddarTech M16 Lidar (45 degree, 16 segments, 100-1000 Hz) monted on a servo:
I’m using MeshLab for visualization – use ‘Normals, compute’ in MeshLab to compute normal vectors for the faces.
Further topics: hectorslam (2.5d slam), rgbdslam (3d slam), octomap (3d mapping)