Our code deploys just fine (and simple robot code will run and we can drive the robot) but our current code deploys successfully, but the driver station does not recognize it and says we have no code. it also gives as this error:
ERROR Unhandled exception instantiating robot org.usfirst.frc.team5340.robot.Robot java.lang.ExceptionInInitializerError at [org.usfirst.frc.team5340.robot.Robot.<clinit>(Robot.java:23), java.lang.Class.forName0(Native Method), java.lang.Class.forName(Class.java:259), edu.wpi.first.wpilibj.RobotBase.main(RobotBase.java:197)]
Please Help!
Robot (1).java (2.66 KB)
Robot (1).java (2.66 KB)
I actually debugged this exact problem last night. For us, it was caused by attempting to two motor controllers on the same PWM channel. Pretty terrible error message.
What I think is happening is RobotBase attempts to load the Robot class by looking it up by name. The Robot class doesn’t exist though because a runtime error occurred during its creation (in our case attempting to open two controllers on the same port number).
I cant check your source code right now, on my phone, but I would start by checking all the port numbers for your hardware iare unique.
The one thing that I don’t like about the new system is that it is much harder to debug code exceptions. The errors you get aren’t really helpful.
We had this same error, it turned out to be that we were trying to instantiate our OI class prior to our subsystems.
Looking at your Robot.java. it looks like you are accessing accessing subsystems that are stored within the OI class?
You also never actually initialize your oi variable. So if you’re likely running into dependency issues which are causing runtime errors.
Instantiate your subsystems within the Robot class.
Instantiate oi in robotInit(), then instantiate any commands after this.
If you need an example of how drivetrain code should be laid out in a command base robot project, there’s a foot example here from team 3019: