Controlling individual BLDC motor in tricopter

Hello Everyone,
I’m making a drone from scratch and I’m using basic programming in arduino IDE and for communication i’m using my laptop to control it’s thrust, pitch, roll and yaw and right now i’ve directly connected to laptop, later i’ll use Node MCU to fly the drone.
But in the coding, I’m having a doubt that how do i control each motors/ESC’s to perform pitch and rolling movement. Here is the code that I’m working on.

And also, I’ve MPU6050 code and now I need to integrate it with my ESC code, But I need some advice that " how should i do?"
I’m uploading my IMU code and the one i tried to integrate.

Pls suggest what should i try next.

ESC_calibrate>>> motor code
MPU6050_gyro_pitch_roll_yaw >>> mpu6050 code
mpu_and_esc >>> motor and mpu integrated code that i tried.

ESC_calibrate.ino (2.23 KB)

MPU6050_gyro_pitch_roll_yaw.ino (1.19 KB)

mpu_and_esc.ino (5.76 KB)

Converting the 4 DoF from control inputs to 4 DoF of the rotors is at heart just:
code] 
  front_left = thrust - pitch + roll + yaw ;
  front_right = thrust - pitch - roll - yaw ;
  back_left = thrust + pitch + roll - yaw ;
  back_right = thrust + pitch - roll + yaw ;

With suitable scaling / limiting applied - its important not to saturate the outputs as then
control authority drops away immediately. In particular pitch and roll should be prioritized I
think.

Non-linearity in the output response (rotor thrust v. its individual control input) should be
compensated for to reduce interaction between the individual control inputs.

What configuration is your tricopter?

Quadcopters, with their matching sets of clockwise and counterclockwise props are able to balance those forces with speed control only.
Most tricopter configurations I have seen have a servo to pivot the single tail rotor for yaw control.
I am curious how you plan yours to be.

Its a very similar problem, there are 4 degrees of freedom still, just different ones. You can isolate
the yaw to the servo for a tricopter and treat the rest as 3 DoF.

vinceherman:
What configuration is your tricopter?

Quadcopters, with their matching sets of clockwise and counterclockwise props are able to balance those forces with speed control only.
Most tricopter configurations I have seen have a servo to pivot the single tail rotor for yaw control.
I am curious how you plan yours to be.

The configuration is, it's a Y shape tricopter... having servo motor on its tail for yaw movement.
The front two motors are rotating clockwise and tail one is on anticlockwise.
it's just as normal as a Y shape tricopter. If the method is incorrect let me know about it. Thnx
Pls do ask if any other query you have.

MarkT:

Converting the 4 DoF from control inputs to 4 DoF of the rotors is at heart just:

code]
 front_left = thrust - pitch + roll + yaw ;
 front_right = thrust - pitch - roll - yaw ;
 back_left = thrust + pitch + roll - yaw ;
 back_right = thrust + pitch - roll + yaw ;




With suitable scaling / limiting applied - its important not to saturate the outputs as then 
control authority drops away immediately. In particular pitch and roll should be prioritized I
think.

Non-linearity in the output response (rotor thrust v. its individual control input) should be 
compensated for to reduce interaction between the individual control inputs.

Sorry,
As i said, I've a tricopter. 1st thing I would like to know what should I be focusing on to balance the tricopter, should it be on mpu6050, to calculate the all x, y, z axis.
2nd thing how should I control each motors for ROLLING and PITCHING movement, pls do read the code that i have uploaded it's as basic it could be and I've been successful to have thrust and yaw movement. I've controlled all the motors at once but not individually.
This is the main thing that I would like to know. Thank you.

MarkT:
Its a very similar problem, there are 4 degrees of freedom still, just different ones. You can isolate
the yaw to the servo for a tricopter and treat the rest as 3 DoF.

that was helpful.

But, I understood the YAW movement and i've been successfull in that. But, I couldn't control DoF of other 3 BLDC motors. Pls elaborate or give an example for it to control each bldc motors.
Thank you.