Non-static method error

I could use help with a error we encountered in our code. We just created a new intake and our code is saying “Cannot make a static reference to a non-static method”. I’m not really sure what we are doing wrong. A picture of the error and a link to our code is below.

https://github.com/TheResistance4925/SWERVE-2023-2024/tree/main

Have you tried googling this phrase?

You defined intakeDirection() as a non-static method. This means that the method needs to be called from an instance of IntakeSubsystem rather than the actual IntakeSubsystem class like you have done here. You would need to call the intakeDirection() method from the intakeSubsystem object you created like this: “intakeSubsystem.intakeDirection();” Since you named your IntakeSubsystem object “intakeSubsystem” with a lower case i.

3 Likes

I have tried a lot of things. Googling it gets me a thousand references to errors that are not FRC examples, and even spending some time (I’m a very novice programmer), I still can’t find something that makes sense. Our team created both a command and a subsystem with a command in it to run the intake, which is where I suspect the error is coming from, but I can’t seem to fix it.

That would be because its not an FRC-spefici error. @Durgabo explained the cause and solution quite well

1 Like

The mistake you made is not FRC-specific; there’s a good explanation posted above but you should read through some of the google results again after checking it and see if you can figure out how the general explanations relate to your specific case.

1 Like

Thank you - that solved it. We were thinking it was some sort of parentheses or capitalization error. I think I understand why it was an error now!

1 Like