Error: "Could not instantiate robot"

Hi,
Something odd is going on with our driver station. Deploying the code to the RIO works fine, but the driver station immediately (while disabled) begins to throw the following error:

5:21:37.482 PM
ERROR: Could not instantiate robot org.usfirst.frc.team2523.robot.Robot! WARNING: Robots don’t quit! Error at edu.wpi.first.wpilibj.RobotBase.main(RobotBase.java:218): ERROR Unhandled exception instantiating robot org.usfirst.frc.team2523.robot.Robot java.lang.ExceptionInInitializerError at [java.lang.Class.forName0(Native Method), java.lang.Class.forName(Class.java:259), edu.wpi.first.wpilibj.RobotBase.main(RobotBase.java:216)]

And complains about “No Robot Code”. Restarting EVERYTHING seemed to fix it for a couple of minutes, but that method has not worked since, and the issue is back.

Any ideas?

Since your code is crashing, I’d suggest you post it so someone can help point out where your coding error might be.

Here’s a link to the git hub repository.

There was an issue with the commented out code in Robot.java. You instantiated CANTalons in the various subsystems, then created more instances on the same CAN IDs in the commented code, which will cause the program to crash.

If you haven’t tested since commenting that out, I would bet that was the issue. Otherwise though, everything looks fine to me (though I’m not the best at finding bugs just by reading code).

Hi,
Through further testing, I’ve come to the conclusion that this isn’t a code issue, but something wrong in WPIlib or the RoboRIO. My reasoning for this is that this error throws at completely random times. Sometimes, my code will run and enable just fine, but the next time it won’t, despite the code not having changed.

There are a few factors that seem to trigger it more than others, however. For instance, changing more than a few lines at a time between deploys causes it, as well as changing the type of any motor controllers, or just using the SPARK type in general.

Has anyone experienced this, and found a way to fix it?

That sounds like a perfect reason for it to be user code.
We call that a timing window-where the error is dependent on the code execution timing.

The error seems to be most problematic when using the Spark controller WPI library. When I switch it to CANTalon sometimes it takes a couple of deploys for the code to be happy again, but I can then deploy the CANTalon version of the code as many times as I want and it stays operational. I’m really at a loss for what to do next. Specifically, this error occurs in BallPurge, where I am trying to have both the lift and intermediate motors turn on at the same time. If it means anything, we are using Sparks in other parts of the code and they have no issues.

P.S. We changed the repository we are working out of, so here is the new link.