Quote:
Originally Posted by ArzaanK
I will take that into account. So if I want the robot to turn at half speed I set P to 0.5, correct?
|
PID gains have real world units attached to them. They aren't just made up numbers.
Consider a simple P controller. It has the form:
Code:
output = Kp * error
What are the units of Kp? Rearrange the equation.
Code:
Kp = output / error
So Kp is a ratio between your output (in this case, the "turn" power from -1 to 1) and your error (in this case, degrees).
Commanding an output of -1 or +1 is like commanding a full speed turn with your joysticks during teleop. For most robots, that's probably pretty fast. Probably way, way too fast to accurately turn only 1 degree.
I would start with a really tiny gain and then move up from there. Try (1/90) or so. This would give full power when you are 90 degrees (or more) off of your goal, half power at 45 degrees off, etc.
What you will likely see is that your robot moves in the general direction of your goal, but stops a little short or overshoots a bit. At this point, you can try upping your P gain, or adding Ki or Kd gains (and by the way, the same principle applies: These gains also have units, and their units involve time as well). You may also find that limiting the maximum output of your PID controller is necessary to prevent overshoots (for example, no matter what, never go more than 50% of top speed).