I became eager to resolve this issue once and for all. There must be a way to compensate the motors when the battery is weaked. I then thought up a solution.
1. The power of the battery can be tested by having the robot run forward at a fixed power level for one second, and have the encoder measure the distance. When the power drops, the robot will travel a shorter distance.
2. By taking multiple measurements of varying motor power and how far the robot travels, via an encoder reading, one can gain the relationship between the motor power and the distance traveled by plotting the points in Excel. To my luck, there was a simple linear relationship. This was found to be DistanceTraveled(L+R) = 4.13*motorPower
3. To produce a perfect 90 degree turn, the values for the encoder and motor values are perfectly set for a specific battery level. So if I make sure the motor is always outputting the same strength, then my robot will turn consistently. I do a gauge of how strong the battery is using step 1. I then set the optimal values for a perfect 90 degree turn. This will be my reference point. Then using the equation for step two, I can compensate the motors to always have the same power no matter how strong the battery is.
This worked beautifully. In my test, I made 300 the reference point for the encoder calibration value. With the weakened battery, it only traveled 272 in that same second. Then with a second powerCompensated run, it shows that I was able to get it back to 301.
This made the motors turn FAR more consistently during battery changes. There were still a few times it'd be off due to the erraticness of the motors. But I adjusted the power compensation factor so that sometimes it'd overshoot it and sometimes it'd undershoot it so that it averages itself out. I was now able to run multiple turns with much different battery values and still have it turn near perfectly, consistently.
SUCCESS!


