I am trying to write a thruster control system that manages an array of custom thruster components. Each thruster has a throttle and a range of gimbal for its Y Axis and Z Axis. Given a supplied vector representing the desired direction of acceleration, the control system should adjust the rotation and throttle within their possible ranges, in an attempt to match the desired direction. Example, a pair of thrusters opposingly angled at 45 degrees from center would gimbal towards each other and cancel their remaining side to side components of their thrust vector to give a forward acceleration.
Essentially, the nomralized sum of the thrust from the individual thrusters needs to equal the desired direction of acceleration. However, this is complicated by the fact that the system needs to work with any number of thrusters. I cannot work backwards and solve for X, I need T1, GY1, GX1, T2… etc. There are also many possible combinations that could satisfy the requirement of thrust being in the correct direction (or none, in which case I want the closest). Secondary criteria would be maximum total thrust, and least torque generated.
I know the physics for calculating thrust, acceleration, torque, etc. So that isn’t a problem. However, I don’t have much experience setting up this type of algorithm.
An idea I have is to limit the throttle of a thruster to ten or twenty increments, rather than the full 0 to 1 range of a float. I would check combinations at random, and assign each a desiredness score, adopting any new combination with a higher score. Is there a smarter way to do this?