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:
So we did lower the steering P from 1.0 to .01 and things are working pretty good now. Still lots of testing to do but on the right track. When I observed the jitter I thought it looked like way over aggressive PID controller. But since we are using SDS modules and SDS code, I expected it to work more or less out of the box. We had to pull the SDS library project into VSCode and start tinkering with the PID values. Note: the SDS library uses the SparkMax onboard PID control.
I was having a similar issue with the SDS template and ended up finding another team’s code that we’ve had no problems with so far. I turned our code into template code and everything that needs to be adjusted for your own drive base has a “//FIXME”. Hope this helps!