How to tune PID values for YAGSL?

How do I easily tune the angle and drive PID values for a YAGSL powered swerve? I have the telemetry verbosity as high so how can I use those values to easily tune the PID?


Drive shouldn’t need PID.

For steer angle, I would start with I and D at zero. To test, just command 90 degree step turns so 0 then 90 then back to zero. Plot the data, get the P value as high as you can without overshoot. That worked for our robot just fine, I was impressed with how fast the response was and how accurate with just P. Within 1 degree very quickly.

In theory, for this type of problem you could likely drive P a little higher and then add just a little D term and it may get a little faster response. That said, P alone will likely be more than adequate. You don’t always need lightning fast response, we even filtered our response down a little.

I see no value in I. The long term error just isn’t there. Being within a degree or two is very good for this type of problem.

If you use advantage scope or frc-web-components you can track measured values against desired values and tune it how @Hybrid_Piper described, you do need a drive PID but that is more than likely just a P value. We also have this repository which we are trying to collect known working configurations in.

What is the easiest way to code a 90 degree turn in YAGSL? I don’t see a “rotate” method and haven’t been able to figure out how to command it to rotate 90 degrees…

You can use the drive method using the same robot translation and specify the rotation. If you want examples you can look at my team’s robot code in frc.robot.commands.Swerve and we have both a SnapRotateDrive command and PreciseRotationDrive command

(Edit i put the wrong link but its fixed now)

Could someone help me understand the difference between drive and angle PID values. Specifically the definition of the angle PID. Is the angle PID the module turning to a location - or - is it the entire robot rotating to a location? I know I am probably guilty of overthinking this… - Jason

BOTH if you turn all the wheels the same amount while driving straight on the floor. You might have to write some code to do that, though.