The Truth About Custom Motor Mixes
The option for custom motor mixes in flight controller software has been around for a tremendously long time, since the early days of MultiWii, long before the current 32-bit revolution took over the flight controller market. There's a ton of information and theories out there, from old wive's tales, to handy web calculators to help an enterprising pilot with this feature, but what is the truth? Is it even necessary?
Back in my early days of multirotor adventuring, I happened to snag a really good deal on an ImmersionRC XuGong 8" quad. Thanks to the asymmetrical "dead cat" layout of the frame I launched a bunch of research into the details of custom motor mixes, doing a bunch of math, and talking to some really smart people along the way to figure out some things that didn't really add up to me about the application of this theory on a flat layout asymmetrical frame. There are tons of theories about how and why to calculate a custom motor mix, and I think it is worth looking at the process I took exploring this, as it is still a discussion I see happening around the multirotor community.
Theories of Calculation
First let's identify the primary theories involved here as to how and why to calculate custom motor mixes on a flat frame (where all 4 motors are pointed down by possibly in an asymmetrical arrangement). There are really two main competing theories in the discussion, and the polar opposites of these theories are what clued me in to this research in the first place.
The first theory is that as motors change distance from the center of rotation, the distance a motor needs to travel per degree of rotation increases as the radius increases. We can address this fairly easily mathematically by the relationship between R and the circumference of the circle, giving us the relationship between R and the distance travelled as (2 * pi * r) / 360, reduced to (pi * r) / 180, or r / 57.296, or simply rounded to 0.01745 * radius, which is more than sufficiently accurate enough for our concept here. What we really care about here is that it is a proportional relationship between radius from the center of rotation and the change in distance required per degree of rotation. That means we can basically calculate a simple ratio between arm lengths where our PID controller gains are increased as the distance of the point of applied force (the motor) gets further from the center of rotation. This is probably the most common theory behind the calculation of custom motor mixes, and the one we typically see used in those web based calculators floating around. It all sounds great up to this point. Sound physics and math, correct? BUT... There's more.. A lot more!
Since I had taken university statics and dynamics recently enough back when I was playing with the XuGong to still have some recollection of what I learned, my immediate thought was to perform those calculations based torque (our second theory), rather than distance per degree. Again there is a fairly simple formula for point torque, radius x force. In this case that means torque (or in the case of our controlled environment the practical corrective force) increases directly proportionally to the radius from the center of rotation. Given the directly proportional relationship and the equal application of variables on all four arms, or points of force, that means if we take this system of thought in isolation, we can calculate a simple direct ratio between our distances to get our motor mix calculations, but in this case PID controller gains would be decreased as the distance of the point of the applied force increases, since the practical applied torque is larger the further from the center of rotation.
You can see immediately that we have a problem. There are two conflicting theories that are assuming exactly opposite applications that neither take each other into account. It’s also immediately obvious that calculating the relationship between the two factors becomes immensely complex, given that in torque the strength of the applied force plays a role, where in the distance per degree calculations it doesn’t beyond the fact that a certain amount of force will be required to move that distance.
Attempting to Relate and Correlate
I quickly realized even torque was an incomplete assessment. To get a more complete picture of what is happening we really need to add moment of inertia to the mix. If we simplify this somewhat to the point moments of inertia at the motors (since we’re assuming the rest of the copter will stay fairly constant relative to itself), we can see some impact related to the applied torque and its relationship to the distance per degree of rotation. The basic formula for a point moment of inertia is I = m * r^2 Since moving the mass further out on an axis results in an increase in the moment of inertia at a square to the radius, we can see that relative to the radius of applied force, the system will actually become resilient to a change in angular velocity at a rate higher than the increase of torque brought on by the lengthening torque arm. This puts us back firmly in the territory of our PID gains increasing as the radius to center of rotation increases. However, the fact that radius is squared in the moment of inertia calculation complicates things, meaning that the relationship is no longer a linear relationship between radius and the need of our PIDC to vary the force applied to the system. The calculation systems that are used for custom motor mixes all use a purely linear approach, which means they are not at all reflective of the real relationships in the system. This also means that the mass distribution is a MUCH more critical factor in these calculations than either of the initial and simplistic approaches above.
This becomes much more complex the further we look at it. While point calculations for moment of inertia are pretty simple, distributed calculations are all but impossible to assess without some really advanced measurement techniques on all but the most simple shapes and distributions. Given the large discrepancies between mass distribution along each axis and the great variance between individual quadcopters, there is essentially no possible way to calculate the per axis moments on such a complex system as a miniquad, and even if we could, a tiny shift in the position of the battery could make a pretty significant change to the results.
UPDATE: A reader wrote in to point out that I didn't complete the calculations here, and he was absolutely right. For the sake of simplicity I didn't spell out all the calculations. To follow the formulas all the way through we can insert the two formulas I mentioned above in the angular acceleration formula as seen below.
Point Inertia: I=m*r^2
Rotational Acceleration: a=T/I
a=(F*r)/(m*r^2), r's cancel...
a=F/(m*r), Assume F and m are constants...
a=C/r, set C=1 for proportional
Clearly given this progression there is a linear relationship between angular acceleration and radius. There's a couple of issues here that are problematic. The first issue here is that acceleration is not linear to time it's exponential to time, so it will have different impacts on P, I and D. The second issue here is that the assumptions in this calculation assumes a point mass only at the motors for the moment calculations, and that is not at all an accurate representation of the whole system of the quad. We have increased material required to increase the length, as well as very uneven and dramatically varying (from frame to frame, as well as from axis to axis) mass distributions across the entire frame.
The end result here is that (assuming a flat motor layout) we really can’t calculate a direct impact on the PID controller based the arm length of our motors in any way that would be reliable enough to matter in a custom motor mix.
But What Does It Mean!?
Now that I’m sure your head is hurting, let's step back a bit and put all this into perspective. We all know people (maybe some of us are those people!) who swear that the custom motor mixes work. If everything we learned is true and the system is really much too complex to really calculate in a way that is useful in terms of custom motor mixes, why are some people experiencing positive results? I believe there are a couple of things to consider here. First is confirmation bias. In some cases users expect to see an improvement so they see one. That being said I don’t think this is always the case. In many cases, given the typical mass distribution and arm orientation, the custom mixes that are being used happen to luckily be making changes that are actually improving the system. That’s not because the calculators and math people are using are actually representative of the system, but simply luck that they happen to align in some instances.
Practically speaking, at the scales we’re seeing in miniquads, the PIDC is easily capable of regulating the differences due motor arm lengths without any additional aid of a custom motor mix. If you want to see your P gains on roll and pitch closer together, using the custom motor mix to get them that way isn’t going to hurt anything because of the way they calculated, but it also isn’t likely to have any major impact on the overall handling of the quad. In the end that is essentially all that a custom motor mix will accomplish, and in reality it is likely compensating more for the asymmetrical mass distribution along the frame than it is the physical locations of the motors on the plane.
I think a big difference in whether folks experience positive results has to do with the modes they fly in.
Accel-based modes are VERY sensitive to even small changes (Like 50-100mm) in location of the MPU from COG / Center of rotor plane, while gyro-based flight modes are mostly immune. This has to do with what is measured... the accelerometer measures relative acceleration and direction, while a gyro is much simpler; it measures changes in angle in 3 planes.
However in real life, the quads we fly are small enough that it is hard to move the MPU very far from the center of the craft. They are also agile and generally pretty symmetrical in terms of thrust points and distribution of mass... our modern, more powerful FCs are capable of making the changes needed more than fast enough to account for any imbalance we could reasonably inflict upon them by dint of poor design.
Wait... I just saw an answer here somewhere; not sure it's a right answer, but an answer...
Yeah that's a valid point, I sometimes forget people still fly in stabilized modes :D Typically I think by the time they're comfortable enough to calculate a custom motor mix, they should be comfortable enough to fly acro. I actually for FPV would recommend never starting in stabilized modes. That's what I did, straight to acro. Never had a problem with it.
Yeah your last paragraph is pretty much what I was pointing out here. If you look deeper into the way the motor mix is being applied anyway, it doesn't really do what people think it does. An interesting conversation to have with Boris if you ever get the chance :D
Well, remember that there is software out there that will calculate a custom motor mix for you. There's even an online calculator that will let you do it graphically and cut/paste the mixes in any MultiWii-based firmware.
It was my experimentation with the KK2.xx flight controller and then moving to newer FCs with more advanced Accel modes that spurred my own research and brought about this understanding about how the two halves of the MPU actually work.
As far as my use of the "crutches"... well, I have "started over" 3 times in my process of "Learning to Fly"; the latest linear progression from Angle to Horizon to occasionally Rate modes has produced, at least for me, much more successful stick time and less frustration. I was already flying in stabilized modes with "toy quads" for a long time before I even knew what "rate" mode in a quad was.
Crashing daily and proud of it,
"...Tongue-tied and twisted, just an earth-bound misfit... I."
Yes, but it's the math behind those mixer calculators that's pretty flawed, and what I was pointing out above. The relationship ends up being totally non-linear due to the r^2 factor in the moment of inertia calculations (totally ignoring the interaction of the other variables that complicate it even further), and then the mixer is not being applied by the FC in a way that makes the impact as expected. As Boris pointed out, it's actually a hold over from the way some old PID controllers did things that aren't even used anymore. The only real benefit to the mixer right now is making your PIDs more similar, adjusting for vectored thrust (A-Tail or V-Tail) or remapping motor outputs. I'd have to check in more detail to see how they're being applied to the accelerometer, but I don't believe it's really any different. Again, it might be helping but it's mostly blind luck IMO, and the fact that we happen to be in a range where the changes aren't that far off from linear.
Also an important point here, as you hit on, it's the distance of the accelerometer from the CG that seems to matter to level modes, not the distance of the motors from the center of rotation, which is all the custom mixers are accounting for.
Well, it is pretty hard NOT to design one of the little quads we fly such that CoG and CoR are more than a few mm away from convergence. My point was that there's a LOT of discussion on the subject, and it's pretty hard not to find things like the calculator above once you start looking, no matter how little you may know.
And I agree... just using the factors it generates without understanding the math it's using usually does more harm than good... as I discovered myself firsthand.
That won't stop dozens of new pilots every day from setting forth on this very same Odyssey I myself traveled years ago. ;)
Read a book.