Moving two motors at the same time autonomously

I have had this problem ever since i was introduced to c++. I have this code written for autonomous but dont know how to make the IntakeGroup and dt move at the same time.

dt.driveFor(20, inches);
dt.driveFor(-20, inches);
dt.driveFor(20, inches);
IntakeGroup.rotateFor(20, seconds);
dt.driveFor(20, inches);

whoops sorry about the screenprint

idk if startDriveFor is a thing but that’s what you need. more than likely if it does one at a time its because the code stops and waits for the drive, the ‘start’ version of all of the commands are non-blocking, so the code will continue to execute.

I know startRotateFor is a thing so a sure shot solution would be to put that in for your intake and move it before the drive statement.

1 Like

the only way i could get it to accept the line is if i wrote it like this
vex::IntakeGroup::startRotateFor(20, seconds);
but i got the error code on IntakeGroup

the error code was ‘IntakeGroup’ is not a class, namespace, or enumeration

How did you declare IntakeGroup? I assume it isn’t just a motor.

EDIT: You shouldn’t have vex::motor::startrotateFor, it’s just like the code in your original post but with a start in front of it

Sorry for being so late. I set my IntakeGroup as a motor_group like this
vex::motor_group IntakeGroup = motor_group(LIntake, RIntake);
i have the same thing for my drivetrain, and my left and right side of the drivetrain.

I’ve noticed problems with motor groups in the past, I just avoid them in favor of calling functions that do the same thing. But honestly if you want just make two statements (one for each motor) it’ll play out all the same. It’ll just be a little bit more legwork.

@jpearman, maybe you can provide some insights? I took a look at the definition file for motor_group and it seemed to be missing all of the 'start’s (startRotateFor, startSpin, etc).
Unrelated to this thread, but I also keep getting errors that my expression result is unused even if its used on the very next line.


all of the “startRotateFor” and related functions are being deprecated and were not added to the motor_group class. In fact, the new preferred naming for motor functions is back to “spin…”, we will keep the rotate naming around for now but new code should be using spin, spinToPosition, spinFor etc.

All of these functions take a final optional parameter that determines whether the function should “wait for completion” or return straight away. The “start…” functions simply called the companion function with this parameter set to false. The “start…” functions were primarily there to support VCS blocks.

Can you elaborate ? Any code that demonstrates this, I’m not suite sure what you really mean.


It doesn’t hurt anything, I just don’t know why I get warnings

**EDIT: ** I only just now thought of taking out the equals sign, that removed my errors. Sorry for the ping, I really should have thought of that beforehand :neutral_face:
1 2 3

1 Like

So is there a way to move them both using motor groups? Or will I need to un group them and make them one by one.

rotateFor a time without blocking is not in the SDK, it doesn’t make any sense really. Just do this.

dt.driveFor(20, inches, false);
wait(20, seconds);

So that would move both motors at the same time?

It should, but obviously I’m guessing what the rest of your code looks like.


This will start the intake group spinning

dt.driveFor(20, inches, false);

command dt (drivetrain I assume) to drive 20 inches, don’t wait for it to complete.

wait(20, seconds);

Now wait for 20 seconds


and stop the intake


Ok so with the Intake.spin and the stop for it i can make it run the entire code

yes, rotateFor(time) pretty much means

start the motor
wait for time
stop the motor

by setting the “waitForCompletion” parameter to false, the drivetrain will do the move while your code then does other things.