Hello,
I was a long time FIRST mentor that hasn’t been around FIRST the last 8 years but I am helping out my son’s team as their programming coach. We have a mk4i swerve drive with Rev Robotics NeoMotors and CanCoders from CTRE.
I was able to implement the 0toAutonomous sample code that is out there and make our drive train move with our hardware / joystick etc. This is my first time using the command-based programming paradigm using Java.
Although we do get a response from each of the wheels when moving the joystick in each direction, they do not go in the expected direction. Granted, we had to make changes to the code to use the Logitech joystick, use the CANCoders and Sparkmax speed controllers, Gyro (amount other things) but in general we are following the same code.
I have a feeling it has to do with the encoder values. I do not have a firm grasp on how the program is taking the raw data and processing it. I’m assuming that the SwerveModule.java and SwerveSubsytem.java get passed the Absolute Encoder’s values and these and can be used at the “set points” for the turning motors encoders to use to set the turn of that motor. If I am correct, then I think there may be something potentially wrong with what our absolute encoder values are. There is a correction factor used to offset the encoders that are in the constants.java file such as:
kFrontLeftDriveAbsoluteEncoderOffsetRad
but I’m not sure how to determine what values to put there. We have tried a few different values but quite often the wheels of the robot are fighting each other. For example, going forward on the joystick may result in the left front going in the opposite direction of the right front and the robot just skids most of the time no matter what direction is being commanded.
I am included a link to the entire VS project here but the key files would be
SwerveJoystickCmd.java
SwerveModule.java
SwerveSystem.java
Constants.java.
Any help on how to troubleshoot this issue and confirming or correcting my assumption on how the swerve drive works would be greatly appreciated. I’ve tried looking for this issue on CD and the internet in general, I would guess a lot of teams using swerve drive have encountered this but I have not been able to find the info to resolve it for our team.
Also, I have had to comment out some code having to do with odometer, Pose and Pose2d and other items because I think it’s not recognizing the associated imports so any help with that would be great too!
Thanks in advance for any help!