To understand PID, you’ll have to read WPI’s documentation. They explain PID really well.
Keep in mind, you don’t actually need to know any of the math. Just know how to use PID in code; you therefore could just look at a WPI example project for swerve drive and use their PID code (what we did lmao), then adjust your KPI values according to the screenshots below.
BTW, as explained in this forum post, it is possible to use WPI’s built-in ProfiledPIDController/PIDController class with CANSparkMax: you don’t have to use REV’s provided SparkMaxPIDController class. That is why I didn’t provide any links explaining SparkMaxPIDController.
Selected screenshots from the PID video:
(How do I set gains for P, I, and D?):

