If you fly FPV drones, you know the pain: hours of test flights, tweaking PIDs by hand, crashing, reflashing, repeat. I got tired of it, so I built a tool that uses neural networks to analyze Betaflight blackbox logs and suggest optimized PID values automatically.
The Problem with Manual PID Tuning
Betaflight's default PIDs work okay for most builds, but if you want tight, locked-in freestyle or racing performance, you need to tune. The traditional approach looks like this:
- Fly with default PIDs
- Record blackbox data
- Open PIDtoolbox, stare at gyro traces
- Guess which values to change
- Reflash, fly again
- Repeat 20+ times
Most pilots give up after step 4. The learning curve is steep, and even experienced tuners rely heavily on intuition built over years of practice.
My Approach: Let the Data Decide
Instead of relying on human intuition, I trained a neural network on thousands of blackbox logs paired with their "before and after" PID configurations. The model learned patterns that correlate specific gyro behaviors (oscillations, overshoot, latency, noise profiles) with the PID adjustments that fix them.
The Architecture
# Simplified version of the analysis pipeline
import numpy as np
from scipy.signal import welch
def extract_features(blackbox_log):
"""Extract frequency-domain features from gyro data."""
gyro_roll = blackbox_log['gyroADC[0]']
gyro_pitch = blackbox_log['gyroADC[1]']
gyro_yaw = blackbox_log['gyroADC[2]']
features = {}
for axis, data in [('roll', gyro_roll), ('pitch', gyro_pitch), ('yaw', gyro_yaw)]:
freqs, psd = welch(data, fs=blackbox_log['sample_rate'])
features[f'{axis}_noise_floor'] = np.median(psd)
features[f'{axis}_peak_freq'] = freqs[np.argmax(psd)]
features[f'{axis}_oscillation_score'] = np.max(psd) / np.median(psd)
return features
The model analyzes:
- Gyro noise profiles across roll, pitch, and yaw
- Step response characteristics (overshoot, settling time)
- Error tracking between setpoint and gyro
- Filter effectiveness at different frequency bands
- Motor noise signatures and their harmonics
What It Outputs
For each axis, the system recommends:
- P, I, and D gains optimized for your specific quad
- Filter settings (dynamic notch, lowpass frequencies)
- Feedforward gains for sharper stick response
- D-term filtering to reduce hot motors
Try It Yourself
I've made this available as a free web tool at FPVtune. Here's how it works:
- Fly your quad with blackbox logging enabled
- Upload your
.bblor.bflfile to fpvtune.com - The neural network analyzes your flight data
- Get optimized PID values, filter settings, and feedforward gains
- Paste the suggested CLI commands into Betaflight
No registration required. Your blackbox data is processed and not stored.
Results So Far
I've been testing this on my own 5" freestyle builds and the results have been surprisingly good:
- Oscillations reduced by 60-80% compared to default PIDs
- Propwash handling noticeably improved
- Motor temps dropped 5-10°C with better D-term filtering
- Stick feel more responsive with proper feedforward tuning
Tech Stack
For those curious about the implementation:
- Backend: Python (Flask) with TensorFlow for the neural network
- Blackbox parsing: Custom parser based on the Betaflight blackbox spec
- Frontend: Vanilla JS with real-time visualization
- Signal processing: NumPy + SciPy for frequency analysis
What's Next
I'm working on:
- Support for more flight controller firmware (iNav, KISS)
- Comparative analysis (overlay multiple flights)
- Community-contributed training data to improve the model
If you're an FPV pilot struggling with tuning, give FPVtune a try and let me know how it works for your build. I'd love feedback from the community!
Built with Python, TensorFlow, and way too many LiPo cycles. Check it out at fpvtune.com.
Top comments (1)
This is a fascinating application of neural networks to a real physical control problem. The frequency-domain feature extraction via Welch's method is a smart choice — PSD peaks and noise floors map directly to the oscillation/overshoot behaviors you're trying to correct.
Your approach reminds me of work we're doing at Elyan Labs with hardware signal processing on IBM POWER8. We use timing jitter analysis (nanosecond-resolution variance, CV measurements) for hardware fingerprinting in RustChain — our Proof-of-Antiquity blockchain. The core insight is similar: real physical systems have measurable, characteristic noise signatures that software simulations can't reproduce.
The fact that you're getting 60-80% oscillation reduction and 5-10°C motor temp drops shows the model is learning genuine physical relationships, not just curve-fitting. Have you experimented with different network architectures? For time-series sensor data like gyro traces, 1D convolutions or attention over the frequency bins might capture harmonic relationships that a standard MLP would miss.
Curious whether you've seen the model generalize across different frame sizes (3" vs 5" vs 7") or if the physical dynamics are different enough to need separate training runs.