Auto Drive 15 second portion

So I am having issues figuring out why my drive is running in circles in auto when i use the drive fwd command I have a call out for it already
This is what it looks like:
void drivefwd(double revolutions, int speed){

RightGroup.rotateFor(revolutions ,rotationUnits:: rev, speed, velocityUnits:: pct);

LeftGroup.rotateFor(revolutions ,rotationUnits:: rev, speed, velocityUnits:: pct);

//When I try using making it drive forward it spins one side then the other it dosent do it at the same time to drive forward the rest of the code works as far as a shooter

wait(1,seconds);

drivefwd(5,80);

Shooter.setVelocity(100, percent);

Pusher.setVelocity(100,percent);

Shooter.spin(reverse);

wait(4,seconds);

Pusher.spin(reverse);

wait(1,seconds);

Pusher.spin(forward);

wait(1,seconds);

Pusher.spin(reverse);

wait(1,seconds);

Pusher.spin(forward);

wait(1,seconds);

Pusher.stop();

Shooter.stop();

You need to make your first statement non-blocking:
RightGroup.rotateFor(revolutions ,rotationUnits:: rev, speed, velocityUnits:: pct, false);
By default, rotateFor waits for that step to complete before moving to the next line of code – which is known as a blocking function. Adding the false makes it non-blocking – it starts that action then continues with the rest of the code.

3 Likes

Adding onto this you can also do your left side as startRotateFor(blah blah blah same stuff)
Then have your right side have
rotateFor( blah blah blah) and they’ll rotate at the same time.

So in actuality it would look like
RightGroup.startRotateFor(revolutions ,rotationUnits:: rev, speed, velocityUnits:: pct);

LeftGroup.rotateFor(revolutions ,rotationUnits:: rev,speed, velocityUnits:: pct);

and that will cause it to drive straight

1 Like

also when you upload code you use ``` on both side of your code

cout << "Hello";