Error keeps happening and we do not know why

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

  • Error at frc.robot.commands.Drive.(Drive.java:22): 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.<init>(PWM.java:63)

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

  • at edu.wpi.first.wpilibj.Spark.<init>(Spark.java:47)

  • at frc.robot.commands.Drive.<clinit>(Drive.java:22)

  • at frc.robot.subsystems.Controllers.initDefaultCommand(Controllers.java:29)

  • at edu.wpi.first.wpilibj.command.Subsystem.getDefaultCommand(Subsystem.java:111)

  • at edu.wpi.first.wpilibj.command.Scheduler.run(Scheduler.java:241)

  • at frc.robot.Robot.disabledPeriodic(Robot.java:116)

  • at edu.wpi.first.wpilibj.IterativeRobotBase.loopFunc(IterativeRobotBase.java:212)

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

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

  • Robots should not quit, but yours did!

This has been popping up constantly and we do not know why.
Please help. Github code link : https://github.com/Joshua-Anderson1/2183-Java-Code.git

In the github code the code we use is in the src main folder.

You’re constructing all of your motor objects multiple times. For instance, you are constructing your 4 motors in DrivingStuff, and then again your 4 motors in Drive. You should only be constructing the motors in the Subsystems, and then using them from the individual commands. You shouldn’t be constructing any motor controllers or groups in your commands, or you’re going to have issues.

Whenever I take it out of the Drive file code it says driveMotors does not exist anymore. So what should I do about that?

You need to have the variables defined in one place, and then refer to them from everywhere else. So Drive commands should import your Robot class (which stores the subsystems) and refer to Robot.mySubsystem.driveMotors for example.

1 Like

Thank you we will make sure to implement this into our code tomorrow we will come back if problems persist

UPDATE: the line of code was changed to:
“Robot.drivingStuff.driveMotors.arcadeDrive(Speed, Rotate, true);”
Following what you had said before. The code is throwing the same errors as before, however in this line of code there is another error. For the segment of code “driveMotors”, we are getting the error that driveMotors cannot be resolved or is not a field.

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