Help! Can not run robot's Java code


When we (the programmers) try to run our robot’s Java code, it waits for a few seconds, then the program crashes. Can anybody help us with this? Any help is greatly appreciated!!

The eclipse uploading text:

The eclipse Riolog text:

The driver station text:

That thread may be useful to you. It seems like since the DS is printing a NullPointerException that something in your code is being referenced before initialization, specifically, during the period that the robot code is trying to start.

As Emile said, it’s a null pointer. If you share your code, we can all help diagnose the problem by looking for what you didn’t initialize.

Also, since it’s not 100% clear in your OP, does the code crash a few seconds after deployment or when it’s enabled?

Ok, here we go.

Sorry I forgot to paste my code in; I was in such a hurry I guess I forgot. Here it is:

Mitch Stokes, it crashes a few seconds after hitting ‘enable’ in the Driver Station. Here’s the process: I deploy the error-free code; the driver station looks good to go; then I hit enable; I can’t drive the robot at all; then like 2 seconds later, it crashes and puts it back to disabled.

This sounds like a null pointer being called in either TeleopInit or TeleopPeriodic since the error comes when you enable in the teleoperated mode. Check all of your calls in those two methods to ensure they’re not referencing variables/objects that don’t exist.

It looks like you didn’t define the String “speed” you use on line 97… could it be because you’re using an empty key for SmartDashboard?

That would be the problem (provided there’s not any other classes that modify speed). However, it is worth noting that the null pointer he/she is seeing isn’t from using an empty string (""), it’s from using a string with no value. That isn’t to say that using an empty string on the SmartDashboard wouldn’t throw a NullPointer or other exception, just that this specific null pointer is thrown by trying to access the value of a non-initialized field.

An issue has been created for this:

So what should I do? I tried looking and changing some things but it still doesn’t work. I really need some help and fast as we have to demonstrate our robot tomorrow.

New code:

The variable speed is still not being assigned after being declared on line 40. It is however still being used with the SmartDashboard on line 97. Likley throwing the NullPointer Error.

On line 40, set “speed” equal to empty string. Ie:

String speed = “”;

Try that and see if it helps.