Issue with encoder feedback with Swerve Drive

Hey Chief Delphi. I am having some issues with my swerve drive units. I am currently trying to get all 4 units to move simultaneously in the same direction. I am using the AndyMark “Swerve & Steer Module” with a Flacon 500 for driving and the pre-installed 775 for the directional control. My issue is as follows:

All of my units seem to be following the encoder count of one of my motors, the rear right. When I try to manually spin one of the motors, say the front left, I expect it to resist me and return to the desired encoder count after movement, but the only one that does that is the rear right one. When I manually spin the rear right, it resists me and returns to its setpoint, but in doing so also moves all of the other motors as well.

I’m not sure how to fix this issue. I hope I explained it well enough if more explanation is needed I will gladly provide it. I also have a link to my current code here: Github Code.

Thanks for any help you can provide.

I have taken a look and haven’t spotted any obvious issues. What I would recommend is to deploy in debug and tick through every line of your code while it’s running through all the methods in DriveTrainSubsystem. The button to deploy in debug mode in VSCode is at the top left. You can see all of the variables and their values as you go through debug mode on the left. Check to see that all of your variables change as they should and identify which step the problem is in. Debug mode has been super helpful for us.

Also make sure that all of your encoders are in the correct DIO ports and plugged correctly.

I actually was able to work out the issue using some online resources and some help from a part-time mentor. We found the issue was that we were running all of the drive train “units”, the directional motors, in one class. The issue was resolved when I broke all of the units into individual classes, which is in there now in a new project. After doing this I did some more research on classes and objects and am now working on making it work and be clean and neat. All of our code should be on there with the previous versions. Thanks for your help though!