Leveling a hexacopter .. Math help please?

Hey there, I'm working on a new project: Hexacopter

I have a 10DOF (3Axis gyro, accelerometer and magnetometer + barometer), I managed to apply a kalman filter to it so I get a clean XYZ output, my main problem is finding the most efficient way to control the 6 motors depending on the angle of the hexacopter to keep it level, does anyone have some advice for me on how to calculate that?

Regards

I would suggest going through the Arducopter site… They have basically done all this and I’m sure their code would provide good examples

http://code.google.com/p/arducopter/wiki/Code

you can also look at the open source MWC code. i think you need a PID or similar function that finds the difference between the current position and the last position and then control the motors from that.