Mk4 SDS Various Code Errors

My team and I recently acquired SDS Mk4 modules with NEOS. We have assembled them and tried setting them up. When we forked code from the SDS mk4 GitHub and updated everything to 2022. However, when we try to run our code, we get numerous errors. One of the errors says that there are multiple instances of a sparkmax with the same CAN ID. We are certain this isn’t a wiring issue as we’ve checked the CAN wires and used the rev hardware client. We also have given IDs to the CAN Encoders and none of those are numbered the same as the sparkmax. The sparkmax is always the front left drive motor (The first one listed in the code under the method CreateNeo)

We also get a CTR: CAN frame not received/too-stale error and we do not know the source of this error. We also get this error 8 times even though we only have 4 encoders.

The message “CANSparkMax instance has already been created with this device ID” suggests a software problem, not a hardware one. You are either creating your motors twice, or you have two motors sharing an id in the code. We could say more if you shared a link to your code.

Regarding the other message, you may find some suggestions in this thread useful, but if it’s only at start up and everything works after that, then I wouldn’t worry.

2 Likes

That error stacktrace is saying that you’re instantiating an object with a CAN ID that’s already in use. This can happen with something as silly as a simply typo, or as complex as a code path causing a command-based subsystem to get instantiated twice. Without code, we can’t say 100%.

What we can say, based on the stacktrace, is that whatever the second one is, is being created on line 109 (in the constructor method) of your DrivetrainSubsystem class.

I’m not personally familiar with the SDS library, so not much more help I can be for now.

I could not get our current code, but this is an earlier version that is still giving us the same errors.

It appears you are creating 2 drivetrain subsystems. One I robot and one in Robot container. Since drivetrain subsystem creates motor controllers you make another one for each can ID. Thus the failure.

1 Like

Yes. Remove this line from Robot.java:

DrivetrainSubsystem driver = new DrivetrainSubsystem();

You should create one instance of each subsystem, usually in RobotContainer.

Okay, will do. Also, not sure if this will resolve the next issue, but we can’t get any of the modules to show up on shuffleboard.

yes fixing the first issue will resolve the second one. The Shuffleboard tab breaks because the data never makes it to the network tables, it breaks upon initialization.

Did you solve your issue?

Yes our code is working, however, it seems like our cancoders are booting into relative mode, as their degrees keep changing back to zero in shuffleboard but we have yet to figure out why.

Good to hear that at least you’ve gotten a little further. You should probably mark Bmongar’s reply as the accepted solution.

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