The obstacle avoidance module is based on ToF (Time of Flight) distance sensors VL53L1. The module is rather small and lightweight so it can fit even 140mm frame
You can read about obstacle avoidance in Ardupilot here
- PROX_ToF PCB and parts
- Ardupilot compatible flight controller (Pixhawk, Omnibus, Pixracer, etc)
- Optical flow sensor (FlowDeck or Cheerson CX-OF)
- Any AVR ISP programmer to flash bootloader
- Your favorite quad, tri, hexa, octo :)
- Assemble your PROX_ToF module and flash a bootloader using AVR ISP and Arduino IDE (See Preparing Software)
- Print a case
- Prepare all the nessesary connectors and wires
- Put your optical flow sensor on the bottom of the case
- Connect the module to flight controller Connection diagram
- Flash a bootloader using AVR ISP and Arduino IDE if you haven't done it yet
- Compile and Upload the VL53L1_MULTI_MAVLINK.ino sketch. If you have any errors regarding libraries, install the libraries to your Arduino IDE from this repository
- Follow the instruction how to build Ardupilot firmware;
- After cloning the repository and succesfull building the ArduCopter firmware, change your board's hwdef.dat file (in my case it is located \libraries\AP_HAL_ChibiOS\hwdef\omnibusf4pro\hwdef.dat bacause I used Omnibus F4 RPO FC):
- Find the CS pins definitions (line #67) and add a line
PD2 FLOW_CS CS
- Find the SPI Device table and comment the OSD SPI (SPI3 DEVID4). Instead the OSD add the optical flow device:
SPIDEV pixartflow SPI3 DEVID4 FLOW_CS MODE3 2MHZ 2MHZ
env DEFINES HAL_HAVE_PIXARTFLOW_SPI
- Comment out the OSD defines (line #135)
#define OSD_ENABLED ENABLED
#define HAL_OSD_TYPE_DEFAULT 1
- Configure and build the copter firmware. Flash your FC
- Using MissionPlanner adjust the following parameters:
EK2_ALT_SOURCE = 1
EK2_GPS_TYPE = 3
FLOW_ENABLE = 1
RNGFND_TYPE = 16
RNGFND_MAX_CM = 140
- Connect to your FC using MissionPlanner and press Ctrl+F button
- Push the Proximity button
- Check that you see the Radar and it reacts to distance change
- Arm and takeoff in Altitude Hold mode, you'll notice that your drone will react on closing up objects trying to avoid any possible collision. Try Loiter.
Thanks to patrickpoirier51 work https://github.com/patrickpoirier51/POC it was a good start for MAVLINK DISTANCE MESSAGE generation
Thanks to Vitaly Puzrin for general thoughts and instructions of writing README