Lidar integration in UDB MatrixPilot - Jeffem/MP5_QuadCopter GitHub Wiki

1. Introduction

This page describes the integration of the Lidar Lite V3 in MatrixPilot software and UDB5. This sensor allows a very precise altitude control at low and medium altitude, up to 20 m. In a future version of MatrixPilot, it will be one of the four altitude sensors which there measurements will be mixed to get the better altitude estimation.

2. Lidar Lite V3

The LIDAR-Lite 3 Laser Rangefinder by Garmin is an essential, powerful, scalable and economical laser based measurement solution supporting a wide variety of applications (ex. drones, general robotics, industrial sensing and more). Measures distance, velocity and signal strength of cooperative and non cooperative targets at distances from zero to more than 40 meters. Offering the highest performance available in a single beam ranging sensor in its class.The new LIDAR-Lite has all of the same specifications as the legacy sensor: Up to 40-meter range capability with 1cm resolution, small size, low power consumption and light weight It can be interfaced by I2C or PWM; this last option is chosen, with 10 µs per cm.

3. MatrixPilot changes

Two new constants are declared in options.h: #define USE_LIDAR_ALTITUDE 1

Another in configUDB5.h #define LIDAR_Trigger _LATA4// Lidar trigger output on RA4 And in mcu.c, RA1 and RA4 are set accordingly: LIDAR_Trigger = 1;_TRISA4 = 0;// digital output _LATA1 = LED_OFF;_TRISA1 = 1;// Input Lidar PWM As the Lidar maximum range is 40 m, meaning 40 ms there is no need to change the standard radio input mechanism which is designed for a 2 ms counter but can count 40 ms as PWM inputs are interruption tasks, processed when they are triggered by external inputs, independtly of the synchronous UDB tasks. Counter variables “time” and “rise” are uint16, overflow is 65536, meaning 32 784 µs. Maximum height must be limited at 32 m. The radioIn.c file is not modified. Mavlink.c reports the Lidar raw data (in mm, in the RCChannel 7). Two source files are dedicated to Lidar : lidar.h and lidar.c, where the Lidar procedures are located.

5. CONCLUSION

Lidar Lite V3 is very easy to integrate into UDB/MatrixPilot :

  • Connect RA4 to input port 7 with a 2.2 K resistor
  • Connect Lidar VDD, Gnd and Output PWM to Radio input 7 And enjoy!