Robot not moving back after stacking in Autonomous

I was working on my Autonomous program for skills. We tested it many times, and it was almost perfect. There was one problem, though. After stacking 5 cubes into the goal, the robot would not move away from the cubes. Here are the two lines I used for stacking and driving reverse after that:34 AM
Can anyone try figuring out why the drivetrain won’t drive reverse?

Most likely, it’s getting stuck on the previous command. Something is keeping the robot from completing that line and moving to the next.


Try putting a print statement (std::cout << “Mark” << std::endl; ) after each command and watch the terminal. You will probably find that one of the commands never finishes. Does the stacker ever move the proper distance?

Looking at the API here:
spinFor has a default setting of true for waitForCompletion

bool spinFor (directionType dir, double rotation, rotationUnits units, bool waitForCompletion=true)

Also setTimeout affects drivetrain. So if you’ve changed it that could also be an issue.

void setTimeout (int32_t time, timeUnits units)
Sets the timeout for the motor group. If the motor group does not reach its’ commanded position prior to the completion of the timeout, the motors will stop. More…

then there is setDriveVelocity, which if it has been set to a very small number …

void setDriveVelocity (double velocity, velocityUnits units)
Sets the velocity of the drive based on the parameters set in the command. This command will not run the motor. Any subsequent call that does not contain a specified motor velocity will use this value. More…

but it is probably the spinFor is blocking like others have said.


To add onto this ^, you could change this by adding

, false

to the spinFor command, then adding a delay afterwards.

It would look something like this:

Stacker.spinFor(forward, 6, turns, false);
vex::task::sleep(2000); //May be wrong syntax, I haven't used VEXcode in a while. 2000 is just a guess
Drivetrain.driveFor(reverse, 11, inches);

Also, are you practicing this with a competition switch, the match option on the controller, or the prog skills option?

I used the programming skills option. It took less than a minute for the program to finish.

See if you can move the stacker for less than 6 turns to get rid of a theoretical timeout on the motors.