but now I’m not so sure…
whether I actually need a horizontal acceleration PID. I’d considered adding the horizontal acceleration PID between the horizontal speed PID and the pitch / roll angle PIDs. Its output would set the angle target for those PIDs, but I’ve come to the conclusion that there is a direct mathematical link between horizontal acceleration (the output from the horizontal speed PID) and the tilt angle target set for the angle PIDs
Consider we want 1g acceleration horizontally, and 1g acceleration vertically to give us horizontal acceleration – i.e. no rise or fall in flight height. Then the power must be applied equally horizontally and vertically, meaning a 45º tilt. Or putting it slightly clearer, the acceleration from the accelerometer is measured in g’s, so if we setup the gains of the horizontal speed PID to output in (approximate) g’s, and denote earth axis acceleration along the x and z axes as aeax and aeaz respectively then
tan(θ) = aeax / aeaz
But for horizontal flight aeaz = 1g. So
θ = atan(aeax)
This means the target acceleration from the horizontal speed PID output (i.e. target acceleration) if measured in units of g maps directly to a target angle for the pitch / roll angle PIDs which is “a good thing”TM as it’s much better than adding a noisy accelerometer PID into the system.