Just to understand better what the problem is, perhaps what you experience is similar to car suspension without anti-roll bars. Meaning that when you accelerate, turn or driving over the curb, mass of the vehicle dynamically shifts so your suspension/thrusters need to produce different amount of force then in static case as they experience more mass pushing on them. For example, car without anti-roll bars turns left, as car still has inertia which keeps pushing it forward, there will be more mass pushing on right suspension and less mass pushing or left suspension. Which will start flipping car even further to the right, as the net result of gravity force and suspension force will be lower than normal and on right side it will be higher than normal.
What anti-rolls bars do is transfer some of the suspension force from one side to another to balance them out.
Just a formula won’t help, you need a bit of algorithm to solve this. Here is a good explanation of how to code it: