No Robot Code

We are having an issue where the code will build successfully but when we upload it to the RoboRio the Robot Code light on the FRC Driver Station remains red. In the terminal we get an error that says the following

“ERROR  1  Could not instantiate robot com.revrobotics.CANSparkMaxLowLevel!  edu.wpi.first.wpilibj.RobotBase.runRobot(”

Do you have the RevLib dependency installed? Do you have a spark max set up on your CAN bus?

Yes we’ve formatted the motor controllers and the chain on wires are done properly so I believe the CAN bus is done correctly. Is there a way i can troubleshoot or test to check if its done correctly

If it builds, then your code dependencies are likely fine (just to confirm though, you’re using the 2022 REVLib, not the older REV vendor library? Open the json file and check the version listed)

If it fails at deploy time, then I suspect the code is trying to access a CAN ID that doesn’t exist (check IDs in the code and compare against what’s on the devices using the REV hardware client. All devices should show up when connected, and should have appropriate IDs)

Yes we are using the RevLib 2022.1.1 and we are certain that the CAN ID’s are correct and are correctly defined.

Is there more to the output at runtime? I’d expect to see a stack trace indicating what line of code caused the error.

ERROR 1 : unhandled exception instantiating robot com.revrobotics.CANSparkMaxLowLevel java.lang.IllegalArgumentException: type must not be null

That’s what it is giving us on the driver station terminal

I’d assume there should be more? See if you haven’t worked much with them before.

ERROR  1  The robot program quit unexpectedly. This is usually due to a code error.
ERROR  1  Could not instantiate robot com.revrobotics.CANSparkMaxLowLevel!  edu.wpi.first.wpilibj.RobotBase.runRobot( 
ERROR  1  Unhandled exception instantiating robot com.revrobotics.CANSparkMaxLowLevel java.lang.IllegalArgumentException: type must not be null

We are not entirely sure what any of this means.

Can you share your code? Ideally via github

Checklist to follow:

  1. Correct RevLib installtaion in Venderdeps.
  2. Correct build.gradle (should have id "edu.wpi.first.GradleRIO" version "2022.2.1")
  3. Correct settings.gradle (String frcYear = '2022')

Ok. Others have posted a few “shotgun-strategy” test procedures to check off common things related to spark max’s.

However, can you be a bit more specific about where your knowledge gap is? Are you struggling to understand a part of the content of the “Reading Stacktraces” documentation? Are you unable to identify a stack trace in the error you see in your console window? Can you identify where the full stack trace is, but are unable to identify lines of code to go look at? Something else?

Keep in mind, what you are seeing is a symptom of a problem, which might have many possible root causes. From the information you have provided so far, it’s not possible to propose a single, guaranteed-successful fix. We have to continue to dive into the details to drive from symptom to root cause.

1 Like

Sounds like you have a null argument somewhere. Remember that when you instantiate a CANSparkMax you have to specify both its CAN ID and its motor type, like so:

private CANSparkMax sparkMax = new CANSparkMax(1, MotorType.kBrushless); // Or kBrushed if you have a brushed motor

Refer to the API documentation.

1 Like

@Gabriel.Rodriguez305 , are you also using the Swerve Drive Specialties Code? We are using it, and are getting a Class Loader Error. It appears for us to be trying to access SparkMax version 1.5.4, when we only have 1.5.2 installed. Is any of this the same for you?

The latest spark max version is 1.5.2. Could you post a traceback?

1 Like

Here’s the stacktrace that I saved.

StackTraceWhenUsingCanSparkMax.txt (57.2 KB)

I saw somewhere (I dont remember where) that we got an error dealing with version 1.5.4, so I have a feeling that the code is trying to reach a SparkMax version not yet released.

Any help is much appreciated, Thanks!

Hmm, that doesn’t help a whole lot. Could you perhaps post your github? Maybe I or someone else will see something that sticks out.

We fixed our issue by basing our code off of this 2022 fork of the SDS template: jasondaming/2022-6391-Swerve (