As you may have read previously, all my testing was plagued with noise. It was corrupting the Euler angles enforcing a very low DLPF of 5Hz which then means important data was lost; the most obvious symptom of which was corrupting the vertical speed – Phoebe was rising to twice her programmed height because the accelerometer data was being clipped.
I’d speculated that the noise could well be generated by Phoebe herself by feeding the PWM signals too frequently creating broad-spectrum jitters in the motors. As a solution I was considering adding a rolling average for the PWM output. But a comment from David in that post suggested a much easier approch – just let Phoebe sleep each loop.
By adding sleep, she updates the PWM less frequently, reducing the number of PWM pulse width changes per second, and thereby reducing the noise – nothing as complex as rolling averaging was needed.
So I tried it just now: I set the sleep delay to 14ms which combined with the processing time of 6ms leads to a 50Hz update. First flight looked much better with the 10Hz DLPF, so I upped it again to 20Hz and it was perhaps the best flight ever: vertical takeoff to 1m as requested, hover over the takeoff point, landing back to the take-off point. No drift because no wind. So many problems resolved by a little sleep.
Time to update GitHub with this radical imrpovement! GitHub updated. I’ve updated the default parameters to match what I was using so all you need to run the same test is
sudo python ./qc.py -f
I’ll produce a video next time I head off down the park – better scenery than the back garden.