VEXCode autonomous will skip drive code

When I run the ‘autonomous skills’ challenge to test the autonomous code, the code will spin the motors to pick up the cubes, but it will not run the motors that drive the robot forward. The coach mentioned that the previous versions wouldn’t fully run that new code correctly until you restarted the brain, so I did that and it didn’t work.

The code is like this:
LeftCube.spinFor(10, turns, false);
RightCube.spinFor(10, turns, false);

LeftMotor.spinFor(540, degrees, false);
RightMotor.spinFor(540, degrees, false);

LeftMotor.spinFor(360, degrees);
LeftMotor.spinFor(540, degrees, false);
RightMotor.spinFor(540, degrees, false);

Out of that code, the only processes that will run are the motors that pick up the Cubes, but when I run Driver Skills, the drive motors work perfectly. Why is this?

Off the top of my head, you probably don’t want the first four functions to all be called in non-blocking mode - this means that the first five lines:

LeftCube.spinFor(10, turns, false);
RightCube.spinFor(10, turns, false);
LeftMotor.spinFor(540, degrees, false);
RightMotor.spinFor(540, degrees, false);
LeftMotor.spinFor(360, degrees);

will all run at the same time, meaning you’re asking LeftMotor to spin for 540 degrees and 360 degrees concurrently - that seems like it might cause some undesired behavior. If you want only the first four commands to run concurrently (i.e., spin the intakes and drive forward at the same time), then only the first three function calls need to be non-blocking, like so:

LeftCube.spinFor(10, turns, false);
RightCube.spinFor(10, turns, false);
LeftMotor.spinFor(540, degrees, false);
RightMotor.spinFor(540, degrees);

If that doesn’t solve your issues, please post your complete program, remembering to wrap it in [code]...[/code] tags for formatting.

3 Likes