ERROR  1  Unhandled exception: edu.wpi.first.hal.util.UncleanStatusException: Code: -1029. HAL: Resource already allocated  frc.robot.model.StarTalonSRX.<init>(StarTalonSRX.java:34) 

Hi I’m trying to figure a an error with our robot when we deploy the code the status light for the Robot Code is flashing on and off the error it is giving us is.

ERROR  1  Unhandled exception: edu.wpi.first.hal.util.UncleanStatusException: Code: -1029. HAL: Resource already allocated  frc.robot.model.StarTalonSRX.(StarTalonSRX.java:34)

Any help you can provide is much appreciated

This generally means you have two controllers of the same type set to the same CAN id.

3 Likes

Agreed. Sometimes this takes the form of constructing the same device in two different classes, rather than declaring it in one and using it in both through arguments.

1 Like

Very good point. @Balmy please post a link to your code on github if you’d like more help tracking this down.

This error means that a device is being created multiple times on the same ID or port. This could happen for creating multiple motors on the same port or for instantiating a class multiple times that instantiates devices.
It would be appreciated if you could link to the code and/or a full stacktrace if you need more help.


This is the code we are using. The error said it was in the starTalonSRX class but im not quite sure how to fix this.

You only added the class files, not the source files.

Do we need the source files? I thought the error was based in what was written

nevermind, i see the issue
It should be good now.

https://github.com/vindang21/2020-code-2989 This is the code. Help is appreciated.

The problem is this line in RobotMap:

    public static int COLOR_MOTOR_PORT;

By not explicitly setting a value, it is being initialized to 0. Then in ColorWheelSubsystem at this line:

    motor = new StarTalonSRX(RobotMap.COLOR_MOTOR_PORT);

It tries to create this motor controller object using port 0. However, the DriveTrain subsystem has already put a motor at port 0 via this in RobotMap:

  public static int DRIVETRAIN_MOTOR_LEFT_1 = 0;

And this in the DriveTrain subsystem:

     leftMotor1 = new StarTalonSRX(RobotMap.DRIVETRAIN_MOTOR_LEFT_1);
1 Like

We are having similar issues, can you look at ours as well? Please
https://github.com/ok-dominic/Felipe-7708-2021.git

Hmmm, the link does not seem to work. Is your repo public?

Also, you will want to post the specific text of the error you are reviving. This is a highly useful and often necessary clue to determine root cause. In particular, if you see how the original poster provided info, there was a specific file and line number which reported the issue (StarTalonSRX.java:34) - this in turn makes the debug process much much more straightforward.

Finally - best practice for requesting help online is to detail specifically where you are stuck, what steps you have tried already, what their outcome was, and why you believe each of these outcomes was not the desired one. This is largely because none of use are aware of what work you have or have not done. It provides clues as to what things could be at fault, and helps folks be better at mentoring you toward self-solving these issues in the future.

Thank you for getting back so early, this link should be corrected https://github.com/ok-dominic/Felipe-7708-2021.git
and as for the errors, this is what we get after we deploy and try to run the driver station

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

  • Error at frc.robot.SwerveModule.(SwerveModule.java:35): Unhandled exception instantiating robot edu.wpi.first.hal.DIOJNI edu.wpi.first.hal.util.UncleanStatusException: Code: -1029. HAL: Resource already allocated

  • at edu.wpi.first.hal.DIOJNI.initializeDIOPort(Native Method)

  • at edu.wpi.first.wpilibj.DigitalInput.(DigitalInput.java:33)

  • at edu.wpi.first.wpilibj.Encoder.(Encoder.java:134)

  • at edu.wpi.first.wpilibj.Encoder.(Encoder.java:94)

  • at edu.wpi.first.wpilibj.Encoder.(Encoder.java:106)

  • Robots should not quit, but yours did!

  • at frc.robot.SwerveModule.(SwerveModule.java:35)

  • at frc.robot.Drivetrain.(Drivetrain.java:31)

  • at frc.robot.Robot.(Robot.java:19)

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

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

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

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

  • Could not instantiate robot edu.wpi.first.hal.DIOJNI!

  • Error at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:304): Could not instantiate robot edu.wpi.first.hal.DIOJNI!

So, I think this is the key - your error is happening during the instantiation of the second swerve module object.

Internally, your swerve module class is hardcoded to always use the same ports for your encoders. However, you have four independent modules - each should have its own unique set of values for which ports are used for the encoders.

One way to fix it is to mirror the pattern you used for your motor ports - you pass them in to the constructor of the swerve module. In this case, you’d add four new integer arguments to the constructor to account for the A/B channels on the two encoders. Then, in Drivetrain.java, pass in the proper unique port indices.

If you aren’t yet familiar, I highly recommend this article for some background on what info is inside a stack trace, and how to use it as part of debugging.

2 Likes

More specifically, this is an issue with the WPILib SwerveBot example from which this code was copied. SwerveBot example crashes on encoder pin overallocation · Issue #3089 · wpilibsuite/allwpilib · GitHub

1 Like

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