Hi everyone, its my first time doing this so I will try to be the clearest as posible.
My team is using for first time a Swerve Drive Chassis, to put you more in context we have a Swerve X that moves only with NEO’s (SPARK MAX), we also use the Thrifty Absolute Magnetic Encoder, and a NAV X. I tried to look up if i could find a solution to my StartCompetition() error, but i really dont understand wheres the error in my code.
It shows you where the error is in the stack trace:
Error at frc.robot.subsystems.Chassis.‹init>(Chassis.java:36): Unhandled exception:
java.lang.NullPointerException: Cannot invoke
"frc. robot.subsystems.Module.getPosition()" because "this.frentIzq" is null
I can’t see the code you uploaded because you uploaded the compiled .class files, not the human-readable .java files, but we can tell on line 36 of Chassis.java, you try to run the method .getPosition() of a Module, but that module has not been created yet. The value of the variable frentIzq is null, meaning it doesn’t exist.
Assuming you’re using the CLI, simply run git add . then git commit from the root of your project (where the build.gradle file is). You’ll want to make sure you’re including the src folder as that one contains all your .java files
Here’s your problem. No value set here, but you try to use it here. The solution is to move the latter line into the constructor after you’ve defined values (so… here)
As an aside, you’ll have the same problem with positions (used on these two lines) once you move the other line.
I prefer to just put all class member instantiation into the constructor for this very reason.