Strange problem about the depth hold mode

The orientation of the board does matter. The sensors that determine the current orientation of the vehicle are on the board. Think about this. If the board is in the normal orientation, and the vehicle starts leaning forward, then the board outputs to the motors to correct for the error and return the vehicle to level. If you turn the board so that the arrow faces the rear of the vehicle, when the vehicle starts leaning forward, the board thinks the vehicle is leaning backwards, because you did not tell the board that it is facing the opposite direction. In this case the board tries to correct for the error and instead of returning the vehicle to level, it pitches the vehicle forward even more, this cycle repeats, and the vehicle flips over.

 

You do not need to make changes to the source code to fix this issue. Fortunately, there is a parameter that you can change so that you can tell the board how it is oriented in the vehicle, so that it can react appropriately. This is what you need to change.

See here: Complete Parameter List — Copter documentation

In qgc, before you calibrate the accelerometer and compass, it prompts for the orientation of the board, you need to enter that setting appropriately for your setup.