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

  • at edu.wpi.first.wpilibj.PWMSpeedController.<init>(

  • at edu.wpi.first.wpilibj.Spark.<init>(

  • at frc.robot.commands.Drive.<clinit>(

  • at frc.robot.subsystems.Controllers.initDefaultCommand(

  • at edu.wpi.first.wpilibj.command.Subsystem.getDefaultCommand(

  • at

  • at frc.robot.Robot.disabledPeriodic(

  • at edu.wpi.first.wpilibj.IterativeRobotBase.loopFunc(

  • at edu.wpi.first.wpilibj.TimedRobot.startCompetition(

  • at edu.wpi.first.wpilibj.RobotBase.startRobot(

  • Robots should not quit, but yours did!

This has been popping up constantly and we do not know why.
Please help. Github code link :

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.