How Does the Smart Drive train calculate distance?

We have been using the SmartDrive system on v5 Pro
I would like to understand how it gets the distance to travel with the driveFor(Distance , units);
We are switching to Mecanum and would like to create our own functions for this.
Thanks

When setting up a drivetrain, it asks for the wheel diameter. This is because it uses the perimeter and rotation to work out distance.

distance = rotations * π * diameter

Which becomes:
rotations = distance/(π*diameter)

The rotations is how many times the robot spins the wheels to get to the correct distance.

A mecanum may work differently as it moves in different directions in relation to the robot. So you may need to factor in trigonometry.

2 Likes

I’m not sure about V5, but I know in IQ it asks for the wheel circumference, not diameter. It’s probably a better idea to just take a flexible tape measure around the wheel, because that way you don’t have to round so much. Suppose your wheel circumference is 9 inches.

Then you just say, “When the wheel spins once, the robot moves forward 9 inches. I have a 2:1 gear ratio, so my motor only has to spin 0.5 turns to make the robot go forward 9 inches. Since 1 turn is 360 degrees, 180 degrees will make the robot go forward 9 inches. That means 20 degrees = 1 inch (180 degrees/9 inches). So if I say, ‘Spin drive motors forward 20 degrees,’ it will go 1 inch.”

2 Likes

I don’t believe mecanums will accurately reflect distance as the wheels do some weird wonky thing that makes them slower, despite being 4"

Thanks, do you have any suggestions to calculate it properly?

You can also write your own function to calculate distance. You can create variables for wheel circumference and gear ratio. The function can accept desired distance to travel as an input and using the circumference and gear ratio values calculate a rotation or degree value to return back, which can be used in the spinFor, spinTo, etc. commands.

I don’t, but you can tune a constant such that when you tell the robot to go 10 inches the constant converts from inches to ticks for the motor. Like trial and error of just running 10 inches again and again with a ruler until the constant goes to 10 inches exactly.

I had programmed mecanum wheels, they acted like 4” wheels when going straight, and I never was able to treat them just like normal wheels when programming, and they always went to the calculated distance with about ± .25in accuracy.(not officially calculated)

4 Likes