Start competition error when code deployed

I’m getting an error when deploying my robot code to the roborio, it looks something like this:

  • 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.

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

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

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

  • 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.PWMVictorSPX.(PWMVictorSPX.java:39)

  • at frc.robot.subsystems.DriveTrainSubsystem.(DriveTrainSubsystem.java:23)

  • at frc.robot.commands.TeleopDriveCommand.(TeleopDriveCommand.java:20)

  • at frc.robot.RobotContainer.(RobotContainer.java:52)

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

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

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

  • Robots should not quit, but yours did!

  • 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!

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

  • 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

Here’s a link to our repository:

THanks!

What’s shown beneath the “robots should not quit” message is the exception (error) that occurred, and below that is the backtrace or stack trace, which shows you where the error is coming from and the series of calls that led to that location. In this case, the error was:

HAL: Resource already allocated

and the first line of your code that triggered the error was:

at frc.robot.subsystems.DriveTrainSubsystem.(DriveTrainSubsystem.java:23)

What this means is that on line 23 of DriveTrainSubsystem.java, you are allocating a PWMVictorSPX on the same PWM port as another device.

The cause is either that somewhere in your code you have another device using that same PWM code, or you are creating your subsystem twice instead of once. In this case, it’s the latter, and the stacktrace shows it, as it goes through line 20 of TeleopDriveCommand.java, which is calling “new DriveTrainSubsystem” even though you already created DriveTrainSubsystem in RobotContainer.

Instead of creating DriveTrainSubsystem again in the command, you should use the one passed to the command constructor.

1 Like

thanks :slight_smile:

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