SDS Swerve Drive Problem

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.

Couple things:
Lower your PID values and see if the jitter goes away and the result is acceptable.

Maybe try increasing the tolerance of your modules say, within 2 degrees.

Finally, if these two things don’t help, can you post your code via GitHub or something?

8 Likes

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:

constexpr units::degrees_per_second_t kTurningPositionMaxVelocity = 2750.0_deg_per_s;
constexpr units::degrees_per_second_squared_t kTurningPositionMaxAcceleration = 20000.0_deg_per_s_sq;

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!

2 Likes

Thanks for the offer of your code. Will take a look.

If the PID is still too violent, look into putting ramps on your steering motors

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