but I’m sure how to fix it.
Imagine a video camera facing the ground over a high colour / contrast surface. If the camera moves forward, the macro-blocks shows forward movement. But if the camera stays stationary, but pitches backwards, then the macro-blocks show a similar motion forwards because the rearward tilt means the camera is now points forward of where it was pointing.
The motion processing code sees this camera rearward tilt as forward motion, and so applies more rearward tilt to compensate – I think you can see where this leads too!
I’m obviously going to have to remove the perceived forward motion due to rearward pitch by applying some maths using the pitch angle, but I’m not quite sure what it is yet. The need for this is backed up by the fact the PX4FLOW has a gyro built in, so it too must have been using it for that type of compensation. The fact it’s a gyro suggests it may not be rotation matrix maths, but something simpler. Thinking hat on.
Just realized I’d solved exactly this problem for height, essentially knowing height (PX4FLOW has URF) and incremental angle change in the quadcopter frame (PX4FLOW has a gyroscope), you can calculate the distance shift due to the tilt, subtract it from the camera values and thus come up with the real distance