Subsystem cannot be null

I am sorry for the lack of resources, but I am not with my robot at present, and thus cannot provide the full stack trace. But basically, I am both command programming my robot and using CAN-based jaguars. So, in my subsystem constructors, I have to add the line “throws CANTimeoutException” because that is where I naturally initialize my jaguars. However, when I compile and deploy my Java code, right before the line in the console that says “GOT_CONNECTION_FROM_CLIENT”, I see a stack-trace that says “Subsystem must not be null”. Again, I apologize that I don’t have the stack trace message, but it basically finds the error in the line of code that says that that the required(whateverSubsystem) line is throwing the exception. I have a strong suspicion that the two are linked. When I commented out this line, I got a CANTimeoutException after the “GOT_CONNECTION_FROM_CLIENT” line when I clicked “Enable” in the driver station app. Naturally, because the subsystem constructors throw the error, so does the init() method of the CommandBase.

Has anyone experienced this? Should I replace all of my “throws” statements with internal try/catch blocks? Other options? I’ll try post the stack trace errors during my Advisory period at school when I can access the robot next, which would be no later than 10:15 AM PST, but it maybe as late as 2:15 PM if that is not possible.

Thank you all.

Is your OI initiAlized before your subsystems?

1 Like

Yes. Does that the commands initialize before the oi is set? That would make sense.

Then one of your buttons’ commands is probably require()ing a subsystem that hasn’t been initialized yet, and is thus null. I’d recommend leaving OI as the last to be initialized.

Yeah, I just realized that. Wow, I can be an idiot sometimes.