Converting degrees into inches similar to using drive train without actually using it?

i cannot use drivetrain option because my robot uses six motors on the drivebase.

is there any way i can program a function that allows me to change this:

frontRight.spinFor(fwd, 16, turns);

to:

frontRight.spinFor(fwd, 16, inches);

We know that the circumference of a circle is 2πr, meaning a wheel will move 2πr inches forward every rotation. So to get the number of rotations you need, divide the total distance you wish to travel by 2πr. Note that 2 * r is the diameter of a circle, so the circumference can also be calculated by π * D, which is more useful since Vex uses diameter for wheel size.

4 Likes

could you show me what that would look like on vex code?

What dimeter are your wheels?

You can use the drivetrain, you’d just have to configure an additional motor for the drive group.

Are you using text or blocks?

You can do something like this:
motor leftMotorA = motor(PORT11, ratio18_1, false);
motor leftMotorB = motor(PORT4, ratio18_1, false);
motor leftMotorC = motor(PORT15, ratio18_1, false);
motor_group LeftDriveSmart = motor_group(leftMotorA, leftMotorB, leftMotorC);
motor rightMotorA = motor(PORT2, ratio18_1, true);
motor rightMotorB = motor(PORT7, ratio18_1, true);
motor rightMotorC = motor(PORT14, ratio18_1, true);
motor_group RightDriveSmart = motor_group(rightMotorA, rightMotorB, rightMotorC);
inertial DrivetrainInertial = inertial(PORT19);
smartdrive Drivetrain = smartdrive(LeftDriveSmart, RightDriveSmart, DrivetrainInertial, 319.19, 320, 40, mm, 1);
Of course, change ports and drivetrain values.

For the specific method you showed, no. The enum is predefined in the vex namespace, and there is no polymorphism for enums.

However, you can write a function that converts inches to rotations. See here for more info
https://www.learncpp.com/cpp-tutorial/introduction-to-functions/

1 Like

Are you sure because that code worked in a comp