Make Drivetrain Move based on a sensor value

Hey guys, I’m trying to make some code that will cause my right motor to move when my left motor moves for a certain sensor value, but when I run it, it doesn’t do anything. Could anyone give me some help? Thank you.

indent preformatted text by 4 spaces

#include “robot-config.h”

void baseSensor(int LeftValue, int velocity )
{
RearLeft.setStopping(brakeType::coast);
RearRight.setStopping(brakeType::coast);
RearLeft.resetRotation();
RearRight.resetRotation();

    RearLeft.rotateFor(LeftValue,rotationUnits::deg,velocity,velocityUnits::pct);

while(RearLeft.isSpinning())    
      {
          RearRight.spin(directionType::fwd,velocity,velocityUnits::rpm); 
      } 

// RearRight.startRotateFor(RightValue,rotationUnits::deg,velocity,velocityUnits::pct);

task::sleep(30);

}
int main() {
baseSensor(1000, 100);

}

RearLeft.rotateFor(LeftValue,rotationUnits::deg,velocity,velocityUnits::pct);

This line blocks until RearLeft.isSpinning() is false.

So how would I fix that?

If I changed the rotateFor function to a startRotateFor one. Would that work?

Yes, startRotateFor does not block so you should be able to see RearLeft.isSpinning() report true in subsequent code before the left motor finishes its move.