You can pass the wheelsLeftMain
and wheelsRightMain
motor_groups
into the drivetrain
class constructor. Or, there is now a 4-motor drivetrain
available from the graphical interface that will do this for you.
As far as using motor_group
s to spin for a certain amount of rotations:
https://api.vexcode.cloud/v5/html/classvex_1_1motor__group.html#a2e9ec313a0ff739204f60f9a90d67d75
bool vex::motor_group::rotateFor ( double rotation,
rotationUnits units,
double velocity,
velocityUnits units_v,
bool waitForCompletion = true
)
So you should be able to do (since both rotateFor
and spinFor
do the same thing):
wheelLeftMain.spinFor(360, deg, 40, pct, false); // The false here says not to wait for the motor group to move the 360 degrees.
wheelRightMain.spinFor(360, deg, 40, pct, true); // The true here says to wait for the motor group to move the 360 degrees. This assumes that the Left motor group will finish spinning at nearly the same time. This assumption may not always be true
I’ve not actually tested this code to see if it works or compiles, but it should be close enough.
If you were to use the drivetrain
class, you would be able to use:
https://api.vexcode.cloud/v5/html/classvex_1_1drivetrain.html#aa1733546f20fadc9358a5d8f9c681aad
bool vex::drivetrain::driveFor ( double distance,
distanceUnits units,
bool waitForCompletion = true
)
Here, you should be able to specify how far, in inches, to move:
dt.driveFor(12, distanceUnits::inches);