4 motor autonomous

Hello,
I’m curious on how to code the autonomous to 4 motors/2 motor groups. Currently when I code it the left side goes the opposite direction of the right. How would I fix this?

Code

motor_group leftDrive(motorL,Motor_L2);
  motor_group rightDrive(motorR, Motor_R2);
  motor_group driverfun(motorR, motorL, Motor_R2, Motor_L2);

  driverfun.spinFor(2, seconds);

  roller.spinFor(3, seconds);

1 Like

If the a side is going the opposite direction, just reverse the direction of whichever side is going the wrong way.

How would I do that without it reversing the whole drive train since if I code it separately it would cause both codes to spin at different times?

The spinFor() code needs three parts. The direction, a number, and a unit. In your code, you don’t have a direction. Yes, it doesn’t come up with an error, but code can be finicky, so I’d put it in like it was designed to do.

Format according to vexcodeV5

This is what it gives for the example

Motor.spinFor(directionType, rotation, units);

Maybe try putting in the forward part, that is possibly the issue, it could be confused on the direction to go.

Also, are you using a mecanum drive? Because if you are, then it would make sense to be using the separated motors, but if you are just doing a normal drive, then I suggest just using the drivetrain device option.

Hope this helps, if not, let me know!

1 Like

I figured it out where I just put the velocity for -80 for one and 80 for the other to even it out.

3 Likes