PID Tutorial

The values I have set for my PID are:
P: 0.075
I: 0.01
D: 0.0

This is for a strafe to distance for a Mecanum drivetrain robot. When we activate the PID the robot moves but it does not oscillate back to correct itself. Are my values too high? I am not sure how to really calculate a PID overall.
Thank you!

Welcome to PID!

First off, this is the standard method I’ve learned for tunin PID parameters:
Set all the constants to 0.
First increment your P until you see controlled oscillation. If you’re getting wild oscillation, you will want to decrease your P.
Increase the D constant until you no longer overshoot.

You will likely never need the I constant in drive trains - that’s more for accounting for a constant “error” (ie gravity on an arm or elevator). Even then, you’re probably better off using a feed forward.

A great way to practice tuning PID is with some simulators. I like to start with this one to tune constants and then use this one for writing full loops

You need to post your code, and get help to see how you may be wrong.

Here is a nice interactive tutorial about how to tune PID.

WPILib documentation:
https://docs.wpilib.org/en/latest/docs/software/advanced-control/controllers/index.html

https://docs.wpilib.org/en/latest/docs/software/advanced-control/controllers/pidcontroller.html

All of those are resources that will help you where you need. With your code, and your exact what you want to do, then we can get you some more specific help.

1 Like

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