The general method that I’m thinking of would be to use the difference in the encoder distances as the error for a PID loop. I would use the arcade drive function, since the PID would “output” how fast you should turn.
Also, when you say “tank drive” it sounds a little like you’re saying you want to use it during teleop. Is that correct? I think it may get annoying for drivers if they want to turn just a little while going forward, and you’ll have other logistical issues to think about.
We would have been fine with doing this for only autonomous but the robot really doesn’t go straight for more than a few feet, which would annoy the driver. We tried adjusting the ratios of motor speeds and went pretty straight for 10 feet, but slower.
In any case, how would we achieve this in autonomous? Give examples in Java preferably.
As stated earlier, you’d be better off using a gyro to accomplish the task of straight driving. When the robot is initialized, the gyro will zero itself. If there is any change in heading, you can use that to create a loop that will steer the robot to correct itself. You may encounter a slight drifting effect, but it shouldn’t be noticeable in a single match.