AUTONOMOUS PROBLEM (Stops randomly)

During autonomous, almost always our skills one (because it is longer) our robot will stop randomly. Sometimes it will go up to a roller, then not roll it, and get stuck, and we push the robot backwards manually and it continues the program. We think this might be because it cannot finish its’ processes, but if it is or if it is not, can you maybe provide advice?
However, the worst part is not that. Now, it will just randomly completely stop mid-code, I don’t know why, and refs at an event I was at didn’t know why. Since then, we have replaced the robot’s brain, but it still does it.
Here is the skills autonomous code:

// "when autonomous" hat block
int onauton_autonomous_0() {
  endgame1.set(false);
  endgame2.set(true);
  Brain.Screen.clearScreen(); 
  Brain.Screen.setPenColor(white);
  Brain.Screen.setFillColor(blue);
  Brain.Screen.drawRectangle(100, 50, 279, 139);
  Brain.Screen.setPenColor(white);
  Brain.Screen.setFillColor(cyan);
  Brain.Screen.drawRectangle(150, 75, 179, 89);
  Brain.Screen.setFont(prop20);
  Brain.Screen.setCursor(6, 22);
  Brain.Screen.setFillColor(cyan);
  Brain.Screen.setPenColor(purple);
  Brain.Screen.print("Roger64");
  Brain.Screen.setFont(prop20);
  Brain.Screen.setCursor(7, 23);
  Brain.Screen.setFillColor(cyan);
  Brain.Screen.print("6390-R");
  roller.setVelocity(100.0, percent);
  shooterthing.set(true);
  intake.setVelocity(100.0, percent);
  flywheel.setVelocity(100.0, percent);
  Drivetrain.setDriveVelocity(30.0, percent);
  Drivetrain.setTurnVelocity(65.0, percent);
  Drivetrain.setStopping(brake);
  Drivetrain.driveFor(forward, 2.5, inches);
  roller.spinFor(reverse, 0.6, turns);
  Drivetrain.driveFor(reverse, 22, inches);
  Drivetrain.turnFor(right, 155, degrees);
  Drivetrain.driveFor(forward, 22.5, inches);
  roller.spinFor(reverse, 0.6, turns);
  Drivetrain.driveFor(reverse, 20, inches);
  Drivetrain.turnFor(right, 240, degrees);
  Drivetrain.driveFor(forward, 123, inches);
  Drivetrain.turnFor(right, 75, degrees);
  Drivetrain.driveFor(forward, 14, inches);
  roller.spinFor(forward, 0.6, turns);
  Drivetrain.driveFor(reverse, 15, inches);
  Drivetrain.turnFor(left, 155, degrees);
  Drivetrain.driveFor(forward, 15, inches);
  roller.spinFor(reverse, 0.6, turns);
  Drivetrain.driveFor(reverse, 13, inches);
  Drivetrain.turnFor(right, 155, degrees);
  Drivetrain.driveFor(reverse, 13, inches);
  flywheel.spinFor(forward, 5, turns);
  shooterthing.set(false);
  flywheel.spinFor(forward, 5, turns);
  shooterthing.set(true);
  flywheel.spinFor(forward, 5, turns);
  shooterthing.set(false);
  flywheel.spinFor(forward, 5, turns);
  shooterthing.set(true);
  flywheel.spinFor(forward, 5, turns);
  shooterthing.set(false);
  flywheel.spinFor(forward, 5, turns);
  Drivetrain.driveFor(forward, 26, inches);
  Drivetrain.turnFor(right, 80, degrees);
  endgame2.set(false);
  endgame1.set(true);
  return 0;
}

Can someone please check this?

You’re driving too far, so the robot can’t complete the motion, so that’s why when you move the robot back its able to complete the line of code it needs to go.

Yeah, I figured that out. As I said, the main problem is it randomly stopping… in front of nothing. It could be in the middle of the field and just stop moving. It happens at various different places too, it’s not consistent.

Is your controller disconnecting?

May I suggest you use EZ template. It is everything you need for autonomous programming, in a simple easy to use interface.
https://ez-robotics.github.io/EZ-Template/

1 Like

Since the autonomous just stops randomly it might have something to do with the motors. If it stops at a different point each time then it might be due to one (or more) of the motors overheating. I suggest trying to use more motors if possible and if it doesn’t go over the 8 motor limit. Not sure if this was any help or not but I tried.

Controller isn’t disconnecting. Also, I am only able to use V5 C++ right now.