I need help finding a conversion factor for my autonomous drive functions. I need a conversion factor/equation for converting inches to autonomous degrees. Every other formula or conversion factor I find is converting autonomous degrees to inches, and every time I try to flip it to get what I want I come up with an answer that does not work with my bot and is wrong. (I am using VexCode v5 Pro text)
Some info would be helpful. What is your wheel size and wheel rpm? you must tune this yourself.
You can convert degrees to inches by dividing the angle in degrees by 360, then multiplying by the circumference of the wheel. You can do this in reverse to convert inches to degrees. (This is for a direct drive)
// Degrees to inches
float inches = degrees / 360 * wheel_circumference;
// Inches to degrees
float degrees = inches / wheel_circumference * 360;
4 inch wheel, 280 rpm
I’m assuming you have an 84:60 ratio. this means that 4pi/360*7/5=0.0488692191 inches per degree.
Thanks! I think this might be it! <33
If I were to change the wheel size, how would that affect the equation?
Your future self will thank you for writing functions to do this:
float degreesToInches(float degrees, float wheelDiameter, float gearRatio);
float inchesToDegrees(float inches, float wheelDiameter, float gearRatio);
change the number in front of pi to the wheel diameter. 4pi=4in wheel, 2.75pi=2.75 wheel, and so forth
Would those be put in the autonomous void section of the code or somewhere different?
No. In C++, you can’t put a function inside another. define it at the top of your code, after the include statements.
Also, would the varying gear ratios change the equation at all?
yes. change the 7/5 to the gear ratio. it is going to be the gear on the motor over the gear on the wheel. The formula could be:
((WheelDiameter * pi)/360)*(motorGearTeeth/WheelGearTeeth)=inches per degree
Right, so later, when you have a robot with a different gear ratio, your code remains the same and you can simply change 1 value (a global gear ratio variable) and have everything just work
So overall,
double inches = (degrees / 360) * wheel circumference * gear ratio
Double degrees = inches / ( wheel circumference * 360 * gear Ratio )
Is this correct ?
This topic is from 2 years ago. Yes, you may receive the answer you’re looking for, but your best bet would’ve been to start a new topic discussing autonomous conversions and questions you have about it or your code instead of reviving dead threads. Thanks!