Why is frc.robot.Robot.ctreConfigs null

Our team is trying to make a swerve drive test bot but our programming mentor is out right now. When I deploy the code to the roboRio it says “java.lang.NullPointerException: Cannot read field ‘swerveCanCoderConfig’ because ‘frc.robot.Robot.ctreConfigs’ is null.”

Here is the git GitHub - Shock-Awesum4961/ChargedUp_Swerve: Attempt to change to Swerve & command based bot

In configAngleEncoder() in SwerveModule.java, this line is referring to CTREConfigs here, which is not initialized. That line should at least be public static CTREConfigs ctreConfigs = new CTREConfigs().

2 Likes

@jdao is right, that is the cause of the problem, but I highly recommend you do not put a public static member in the Robot class like that.
The CTREConfig variable should be local to the configAngleEncoder method, it has no business being in Robot or being static.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.