# An insight into the bloomin’ obvious

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) ```

``` #================================================================================== # 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) ```