We have several autonomous routines that we have been using all season long without any problems. Our code only does basic commands such as resetRotation, RotateTo, etc. But we have had a strange problem come up a couple of weeks ago with a specific routine and I thought I’d post it here to see if anyone has any suggestions as to what we might try.
The problem is that this one routine we have put together simply stops at the exact same point about 50% of the time. This would be easier to troubleshoot if the problem occurred all the time or not at all . We will try something new and think the problem is fixed after several successful runs, but then the problem starts back again.
Here is the code the routine starts with:
LeftFrontDriveMotor.resetRotation(); RightFrontDriveMotor.resetRotation(); LeftBackDriveMotor.resetRotation(); RightBackDriveMotor.resetRotation(); LeftFrontDriveMotor.rotateTo(200,rotationUnits::deg,25,velocityUnits::pct,false); LeftBackDriveMotor.rotateTo(200,rotationUnits::deg,25,velocityUnits::pct,false); RightFrontDriveMotor.rotateTo(200,rotationUnits::deg,25,velocityUnits::pct,false); RightBackDriveMotor.rotateTo(200,rotationUnits::deg,25,velocityUnits::pct,true); //Here is where things stop if the problem occurs LeftFrontDriveMotor.resetRotation(); RightFrontDriveMotor.resetRotation(); LeftBackDriveMotor.resetRotation(); RightBackDriveMotor.resetRotation(); /* Pick up the row of four cubes */ IntakeSpinMotor.rotateTo(2500,rotationUnits::deg,85,velocityUnits::pct,false); IntakeSpinMotor2.rotateTo(-2500,rotationUnits::deg,85,velocityUnits::pct,false); RightFrontDriveMotor.rotateTo(630,rotationUnits::deg,15,velocityUnits::pct,false); LeftFrontDriveMotor.rotateTo(630,rotationUnits::deg,15,velocityUnits::pct,false); //(much additional code follows after this
This code is during the 1 minute timed skills routine. When we say the program suddenly stops, the countdown doesn’t stop - it’s just that the next statement doesn’t execute. There have been only 2 or 3 times that, after an extended pause (anywhere from 2 to 5 seconds), the program will actually continue and finish. This got us to thinking tonight that maybe we have a bad cable somewhere with an unreliable connection. But if this is the problem, it only happens on this one routine.
We have tried using a different Brain (in case the firmware has somehow been corrupted). We have confirmed that wireless connectivity to the controller is maintained throughout. We have tried pairing to a different controller. We have replaced all of our smart cables with new ones. We have tried putting the program in different slots on the brain. We’ve tried replacing the motors. We’ve tried compiling with both VCS and VexCode. We’ve tried commenting out all other code other than what we posted above. But nothing seems to remedy this problem. It’s hard to understand how the program will work some of the time and simply stop executing others - without any code changes being made. If we literally run the routine 20 times, it will work fine about half of the time. There are no similar problems in any of our other routines or in driver control.
At the moment, we are thinking the problem is just buggy V5 language and that maybe we can fix this by adding in an abundance of brake commands , sleep commands, etc. to make quadruple sure that no previous command is still executing or overlapping. I don’t think we should have to do this, but are lost as to what else to try next. In troubleshooting,/testing, we have been able to change some of the code (i.e. the direction and velocity of the motors) and, after this, the problem sometimes seems to not occur as often. In fact there have been several times that we thought we had eliminated the problem , but on attempt number 7 or 8 the problem would return.
If anyone has also experienced this or has any thoughts on what we might try, we would love to hear any suggestions.
Thanks so much!