Control parameter tuning

I am interested in knowing how the control laws in pixhawk are made.

I have used the pixhawk with Ardusub firmware to make 6-thruster 6-DOF ROV, that has more powerful thrusters. I have found it difficult to tune and think understanding the control laws inside the pixhawk will help alot.

I assume they are working like the diagram below for attitude controls - the top one for manual and bottom one for stabilize.

QuestionForBlueRoboticsForum

However, I see there is also some feedforward somewhere, how does that play in?
And I dont think I understand the position controls - acceleration and velocity are used in feedback? There is also a P gain in the parameters for lateral motion, but I thought this coordinate could not be measuered by any sensor on the Pixhawk.