Start Competition Error with Swerve Drive

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.

If someone could help me please would be great, if you need more information about something just tell me. Thanks :slight_smile:

Heres the updated code now

That’s not your code, the bin directory contains compiled .class files, not your source files (.java).

That said, your problem is right in that screenshot. This page should
help you interpret it: Reading Stacktraces — FIRST Robotics Competition documentation

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.

How do i upload the code correctly? And let me check the link, ill give you an update:)

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

1 Like

ready, i just updated my code. Btw, i think i did created the frentIzq variable in my code. Here is the code correctly upload, so you could check

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.

1 Like

WOW! Thanks it did work, I just load the code and i didn’t had any error, but now I have the problem that at TeleOp it doesn’t move :melting_face:

1 Like

Update: I moved the kP and the kD values on the PID of each module and now when you enable the TeleOp period it gets crazy and moves by itself. :pensive:

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