I am Having Problems With My Java Drive Train Code But I Don't Know What The Problems Are

(I’ve never used ChiefDelphi before so please let me know if I need to include more information) I have been having errors in my Java drivetrain code but I can’t seem to figure out what the errors are. I’m not sure if there’s something wrong with my system, if there’s an issue with code not being written properly, or if I just don’t have certain libraries.

(Since I am a new user I can only put one image at a time, so I am going to reply with the other images) On each image, it will say what part of the code it is in on the left-hand side.

As I said before, I’m not sure what the issue with the code is, I’ve tried to do the quick fixes in VS Code but they don’t work. Any help on what to do to try and fix it would be greatly appreciated!

2 Likes

1 Like

1 Like

1 Like

Have you added the REV (maker of the SPARK MAX) vendor libraries?

When declaring things you need to include the type if you haven’t already:
private final CANSparkMax frontLeft = new CANSparkMax...

Lastly, is getflEncoderPosition() something you made cause it can’t find it? I believe getEncoderPosition() is valid.

If you use DifferentialDrive the deadzone (called deadband) is built in and you don’t need special stuff to do it!

1 Like

You reference “controller” here. I think what you want is similar to what you have in getControllerRightX() which is if (m_driverController != null)

None of these things have worked. VS Code says that CANSparkMax can’t be resolved to a type and that’s why there’s an error on frontLeft, backLeft, etc. It does have the sparkmax vendor libraries but still gives the same errors.

Do you have your code on github or anywhere we can fully browse it?

Maybe it isn’t imported? Can you click on CANSparkMax and then click the lightbulb that pops up to the left of it and there should be something about import. The same is true for DriveTrainSubsystem.

I imported what was needed for CANSparkMax, and that got rid of that error. There’s still errors for kBrushed, and it says that “it cannot be resolved or isn’t a field”. I’m not sure what to do to fix that.

When you click on kBrushed and then the lightbulb does it have an import for you?

It doesn’t even have the little lightbulb to the side when I click on it.

Can you confirm you have: import com.revrobotics.CANSparkMaxLowLevel.MotorType; at the top? If you don’t then clicking to put your cursor within the thing that is underlined should add a lightbulb to the left.

Otherwise just put that at the top with the other imports.

I added in import com.revrobotics.CANSparkMaxLowLevel.MotorType; and that resolved the error for .kBrushed but I’m still having errors with the frontLeft, backLeft, etc.

Did you see my suggestion for those above? Can you show what you have?

I managed to get rid of all of the errors in DriveTrainSubsystem with some fenagling but I still have errors in Robot and RobotContainer

For container you need a capital Z and to look at my controller comment above

For robot I am not sure why you have drivetrain stuff there. Remove it

I’ve fixed the things related to controller but I am still have issues with DriveTrainSubsystem and driveTrainSubsystem. Do you have any idea what the problem could be or how to fix it?

You don’t have DriveTrainSubsytem imported in your RobotContainer.

I’m new to programming and I’m not sure how to do that. What do I need to do?