Why can’t I use inches?

For whatever reason, when I try and use inches on my code, it gives me an error. I looked at the vexcode page and it said I could use inches. Why isn’t it working?
This is my code:
Brain.Screen.print(“VELOCITY SET”)
Brain.Screen.print(“BALL PICKED UP”);

It’s giving me the error on “driveTrain.spinFor”

because inches is not a unit you can use. when you’re telling a motor to spin, you have to specify it in rotational units. if you want to use inches, you’ll have to make a function that converts inches into revolutions (or degrees).

to do this, you’ll need to use the relationship between revolutions and tangential distance, which is:

distance in inches = wheel circumference*revolutions


If he is using the drivetrain class, than it would work in inches. So I guess the logical question is are you using the drivetrain object in your program or do you just have a motor group named driveTrain?

Also, tip for posting code in VEX Forum:

Use ``` at both the beginning and end of your code.


I’m not super familiar with the driveTrain class, since I’ve never used it, but looking at the documentation on it, SpinFor only accepts rotational units. Drive or DriveFor seem to be the things that accept linear units.


I can’t see that spinFor function in the drivetrain class. That might just be the error. Again, @angrycoder,
are you using the drivetrain class or did you just name a bunch of motors “driveTrain?”


I used a motor group

You won’t be able to use inches if you have a motor group. You have to set it up as a drivetrain object and use the drivetrain class.

1 Like

or alternatively just control the motors independently without a drivetrain class. I think you can get a lot more control over what yours motors are doing if you just control them individually.

of course for autonomous you can use functions to make it easy to control them as a group.


This is also a great learning experience, so its a lot better to do this. There are a lot of threads in this forum about this.


Note: All of these responses, including this one, are unofficial. But for the meantime I hope we can be of help until you receive an official response.

I highly agree, the vexcode drivetrain system is way too simple and the choices are too restricted.
If you want the motor to turn x amount of inches forward, you will need to convert the inches to rotations:

#include <math.h>

# Settings
wheelDiameter = 4; // inches;

double getDesiredRotations(diam, distance){
double circumference = (M_PI * diam);
double revolutions = distance / circumference;
return revolutions;

// I wanna go x inches
inchesToMove = 24; // Inches

// Get revolutions required to achieve x distance
motorRevolutionsToMove = getDesiredRotations(wheelDiameter , inchesToMove );
motor.spinfor(fwd, motorRevolutionsToMove, rotationUnits::rev);

If you are using a smart drive, then the command would be
drivetrain.driveFor(DIR, NUMBER, INCHES);
If you are not using smart drive i’d suggest you switch or you’d have to figure out how many rotations are in an inch for your drivetrain.


Thank you all very much! Thanks to you guys, I was able to solve the problem :smiley:

1 Like

Can you put this command in the code or would you have to calculate this manually? And if you can implement this command in your code, where would you put it?

Please do not revive threads older than a year old.

Did you really just revive a 2 year old thread?

Good luck with the mob.

1 Like