Code crashes as soon as I deploy it

Hi everyone, I am having this issue where my code immediately crashes upon enabling the robot. It builds and deploys fine. Has anyone had this issue before, and do you know how to fix it?

There’s not much we can say without more information.

When you say “crashes”, what exactly do you see? Does the driver station comm light stay green but robot code light go red? Something else?

Is there any output in the DS logs? If its hard to read in the little window on the right side of the DS, you can open up the log file viewer or console from the gear icon. Or watch the riolog window that appears inside vscode after a code deploy. I’d expect to see an error message and stacktrace (especially if youre using java) if it’s crashing.

Speaking of, what language are you using? Can you share your code? Preferably as a link to github or some other online source control repository.

Odds are, this is caused by a bug in your code. More info will help to confirm this, and to pinpoint it. It’s also possible that something in your control system is contributing to the problem – for example, a wire coming undone can sometimes lead to code that was working causing such crashes. Preseason is a good time to learn how to debug these problems.

When you’ve got an immediate crash that’s hard to debug, it helps to comment out all of the code from your init and periodic functions, make sure that runs without issue, then slowly uncomment parts to add code back in until you find the code that crashes.

Easily half of my debugging skills amount to reverting the code to a known good baseline and then re-adding new code until I find the problem.

For the future, it also helps to make small changes and run them often. If you throw a bunch of new code in all at once, it becomes very difficult to know where it went wrong.

When I try enabling the robot, the code light stays green for about one second, then turns red. Then the robot disables itself.
I looked through my code and realized that I forgot to include one of the device IDs for a motor controller. Could this cause that issue? And yes, I will try to link my code. I tried to do that when I initially published this question but I was having a problem with it. I’m using Java.

It would depend on when that controller object is constructed/used, but yes that has the possibility of causing code to crash, and should trigger a stacktrace to appear in the logs like my previous comment noted.

Missing motor ID very well could do this, because you are using Java have you looked the the stack trace that is printed out, this should guide you to the line of code and which file is causing the crash.

This is what I see in the RioLog.

Awesome, well there’s your problem. is null

You can find more info about how to read these here: Reading Stacktraces — FIRST Robotics Competition documentation

The thing that I do not understand is the fact that I have not used “” anywhere in the code.

Not even on line 138 of
(from: frc.robot.Robot.teleopPeriodic(


Can you share your code? Github repository would be best, but even a screen shot of Robot near line 138 would be helpful

Can you post that line 138 of

The variable won’t be named “this”, it will be whatever name you gave to the army type.

army.arm() on line 140 is using army. Do you initialize that variable anywhere?

army.arm(....) is equivalent to since army is defined as a class member variable

Okay, thank you for clearing that up for me.

Screenshot 2023-09-14 175436

So that’s within the army class. You must have an army variable in the Robot class too–that needs to be initialized as well (e.g. army army = new army();).

Side note: it’s a lot less confusing if you name classes with capital names instead of lowercase.