Sensor fusion
Dec 2021 - Jan 2022
Overview
I had a drone frame and motors, but no way to make it fly. The goal was to make an autonomous drone from scratch. The drone still has not flown, but I did succeed in fusing the data coming from the accelerometer, gyroscope, and magnetometer into an accurate estimate of the actual angle of the drone.
I developed an algorithm that did basic filtering and processing of the signals coming from the sensors and accurately gave the absolute orientation of the system. In order to do this, I had to learn how to do quaternion math, which itself was a challenge. I developed the algorithm first on a Raspberry Pi in Python, then translated it to C++ for an Arduino.
The next step was to program a PID loop that would control the motors. The actual angle of the drone, as computed by the algorithm, was compared to the desired angle. In order to send commands to the Arduino microcontroller, I put the Pi on the drone, plugged it into the Arduino via USB, and connected to the Pi over Wifi.
After a couple of tests, I realized that I needed a more reliable and faster was to communicate with the Arduino. A radio controller/receiver is the right way to go about it, but I don't have one of those. In addition, I didn't have a good way to test the drone safely. I didn't trust my software enough to fly it untethered.
Someday soon I hope to pick this project up again. The plan is to use a Pico this time, which has a lot more power than an Arduino, and to buy a proper controller for testing. Once I have the flight controller working reliably, I hope to move on to autonomous control, using GPS, ultrasonic sensors, and possibly computer vision. All of the higher level control would be done on a Raspberry Pi computer, which would feed commands to the Pi microcontroller.