Our team are swerve noobs but taking the plunge. We have built a drive base using SDS MK4i modules, Neos, Sparkmax, CANCoders and Navx. We have code based on the SDS Java Template and SwerveLib. Testing the drive, it seems to be trying to perform as we expect. If you provide input that requires the wheels to be steered away from straight ahead, the modules try to obey the rotation input but as they rotate to steer they jitter violently.
A theory is that the PID controllers controlling steering are oscillating around the target steering angle.
We have tried another swerve project by Sean Sun, and while it behaves differently in some respects, the jitter issue is still present.
This jitter problem prevents us from really testing and determining how well either code base works.
I know there is other code out there but wanted to see if there are any ideas about this before switching.
Use motion profiling – since you are running the control on the roboRIO, this will be WPILib ProfiledPIDController. This was a huge difference for us, we can set I and D to 0, so we really only have to tune P. The steering works great – up in the air, or on any surface we’ve tried, with the same tuning. You can get pretty aggressive with P.
You do need to provide the maximum velocity and acceleration. We measured these, but you can at least start out by guessing. We code using C++, so we have units – you will have to pay attention to these with Java. But, here is what we run: