Swerve Turn Motor PID question

I am looking at the WPILib example C++ code for a SwerveBot. I noticed that they programmed the drive motors with frc2::PIDController and the turn motors with frc::ProfiledPIDController

From what I understand the profiled PID creates a trapezoidal response for the acceleration in the turn motor, whereas the drive motor is a traditional PID. Is this understanding correct and what is the reasoning behind doing these two PIDs differently.

Drive motors, you typically only care about getting up to speed and maintaining it. So a traditional PID controller makes sense. Azimuth motors (rotation), you are more concerned with moving from position A to position B. Trapezoidal motion profiling is, when tuned, the most controlled method of doing that. Controlled in the sense that you don’t oscillate, you don’t over-exert the motor, and is arguably the fastest path between those points.

9 Likes

Hello , but my turning motor can’t move . Is its kP too small ?

Does it turn if you just send it a straight value? Like if you forgo the PID for a moment, and just send it .75 or 1? If not, you’ve got an unrelated issue, probably mechanical or wiring.

Their swerve drive moves, and they can run characterization, so it seems like a software integration issue.

They’ve been replying to every swerve-related thread they can find in the last week. Here’s a handful of them with more info:

2 Likes