Back down the park this afternoon. The wind had picked up so other than a very minor tweak, I left this morning’s configuration for DLPF, tau and the absolute angle PID gains alone.

Instead, I tried a few flights with the drift-compensation enabled. And it was garbage as it had always been, doing all sorts of wandering round completely unrelated to the tail wind that was blowing at maybe 10mph.

And then I realized what was wrong – I was using the accelerometer X and Y axes to calculated any horizontal speed; What I should have done is much like I use the z-axis accelerometer for vertical speed. Essentially, all the power is upwards from Phoebe’s point of view. Then it needs to be converted to earth axis by accounting for the angle of tilt. Then you can sum that up over time to get the speed. So instead of this bit of code:

` #==================================================================================`

# Axes: Convert the acceleration in g's to earth coordinates, then integrate to

# convert to speeds in earth's X and Y axes meters per second

#==================================================================================

eax = fax * math.cos(pa)

eay = fay * math.cos(ra)

eaz = faz * math.cos(pa) * math.cos(ra)

it should read

` #==================================================================================`

# Axes: Convert the acceleration in g's to earth coordinates, then integrate to

# convert to speeds in earth's X and Y axes meters per second

#==================================================================================

eax = faz * math.sin(pa)

eay = faz * math.sin(ra)

eaz = faz * math.cos(pa) * math.cos(ra)

thus sharing the power from the blades across the 3 axes depending on the pitch and roll tilt.

I knew what I was doing was wrong; I knew the correct fix was todo with vectors; I also knew I’d completely forgotten how they work and that even when I did know, they made my head hurt. So instead, I’ve gone for the flash of inspiration approach which is even more satisfying!

I’ve not tested this yet, due to inclement weather coming in, but I do believe testing in the park, and so not having to worry about catastrophic crashes has allowed my mind to wander constructively.

I’ll be back there tomorrow to test this out – forecast: “sunny with 20mph winds”; should be fun!