We are currently using swerve drive wheels from Swerve Drive Specialties made by team 2910. How do we calculate the number of ticks per revolution for a wheel?
One way you could do it is to first divide encoder ticks by the per encoder rotation and then multiplying that by your gear ratio. This will result in wheel rotations which you can then juat multiply my the circumference of the wheel to get distance.
In our code last year we had a constant that was equal to the amount of ticks equal to one inch of travel. While the formula I said above works really well, it is often hard to determine the circumference of the wheel without taking the wheel off. To overcome this we drove a predetermined distance forward manually (in our case usually 10 feet), averaged the encoder readings, and then divided by the distance we drove.
Second this. Empirical data definitely supersedes pure math in these cases, especially because wheels wear, and some at different rates than others if your wheels are not all on the same plane.
While doing this make sure the backlash in the system is removed. There are a number of ways to accomplish that, but the easiest is to move the bot in the same direction you will be measuring distance before you begin.
I am not a programmer by any stretch of the imagination, but it may be reasonable if you have uneven wear on swerve module wheels to do what Kaboomboom3 recommended, but instead create individual ratios for each wheel. Programmers, feel free to slap my wrists if this is frowned upon.