Robot decided to quit

So our code builds successfully and deploys successfully but when we pull up our drive station, communications are solid but the robot code light stays red. We also get this message in our RioLog:

“Robot should not quit, but yours did!
at frc.robot.Robot.robotInit(Robot.java:114)
The startCompetition() method (or methods called by it) should have handled the exception above.”

Any thoughts?

You should have a much more detailed exception message that should tell you exactly what threw an exception. If that line is the only message you got. Then you likely have an issue at like 114 in Robot.java where you are calling object that hasn’t been initialized correctly or something else of that nature.

It helps to upload your code to a website like GitHub and then link it here for more specific help.

1 Like

I’ve always thought every team should have a written plan–posted for everyone to know-- for if their robot becomes sentient.

It happens all of the time in the movies…

1 Like

The detailed message you are looking for is called a “Stack Trace”. Here is my favorite tutorial for itnerpreting stack traces in java.

  • ********** Robot program starting **********

  • NT: server: client CONNECTED: 10.65.69.11 port 49732

  • Unhandled exception: edu.wpi.first.hal.util.UncleanStatusException: Code: -1029. HAL: Resource already allocated

  • Error at frc.robot.Robot.robotInit(Robot.java:114): Unhandled exception: edu.wpi.first.hal.util.UncleanStatusException: Code: -1029. HAL: Resource already allocated

  • Robots should not quit, but yours did!

  • The startCompetition() method (or methods called by it) should have handled the exception above.

  • at edu.wpi.first.hal.PWMJNI.initializePWMPort(Native Method)

  • at edu.wpi.first.wpilibj.PWM.(PWM.java:62)

  • at edu.wpi.first.wpilibj.PWMSpeedController.(PWMSpeedController.java:25)

  • at edu.wpi.first.wpilibj.Spark.(Spark.java:52)

  • at frc.robot.Robot.robotInit(Robot.java:114)

  • at edu.wpi.first.wpilibj.TimedRobot.startCompetition(TimedRobot.java:64)

  • at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:276)

  • at edu.wpi.first.wpilibj.RobotBase.startRobot(RobotBase.java:348)

  • at frc.robot.Main.main(Main.java:27)

  • Warning at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:291): Robots should not quit, but yours did!

  • Error at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:293): The startCompetition() method (or methods called by it) should have handled the exception above.

  • NT: server: client CONNECTED: 10.65.69.177 port 50763

This is what I am assuming is one run though of the error message.Here is the link to the code:

Seems like you have set two Spark motor controllers to the same PWM port.

Line 110 and 114.

Spark intakePWM2 = new Spark(1);

Spark shooter1 = new Spark(1);

That did the trick. Thanks

Constants like the 1 in:

Spark(1);

are called in programming parlance, Magic Numbers, and are considered poor practice - it’s hard to spot conflicts like the duplicates here, and to find constants buried in the code.

The preferred practice is to declare all the constants in one place:

final int intakePWM2value = 1;
final int shooter1PWMvalue = 2;

and when the speed controllers are instantiated:

Spark intakePWM2 = new Spark(intakePWM2value);
Spark shooter1 = new Spark(shooter1PWMvalue);

This has a couple advantages - first, it’s easier to spot duplicates, and it’s easier and safer to find and, if necessary, change a value if they’re all declared in one place, rather than look for a “1” buried in the code.

Larger programs often put all these constants in their own Class, named “Constants” or “RobotMap”, along with joystick and button numbers, etc.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.