Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

This is borderline non-gamedev but PIDs are commonly used in games so I thought I'd give it a shot.

I've got a few PID controllers in my game, used for things like steering and throttle control. I'm having trouble tuning them accurately. It never feels like I'm getting closer to the optimial solution, and it's very tempting to just leave them "good enough" with the odd oscillation or spike I can't get rid of.

The one controller that's driven me to this post with frustration produces minor oscillations for very very small error inputs. At large inputs it's ok but not very stable.

Does anyone have any tips or resources on how I can train these things more reliably?

share|improve this question
    
I don't think controllers are stable. Are you married to the idea of using a PID controller? If not could you explain a specific case in more detail, I might be able to give a more stable solution. –  Jonathan Fischoff Jul 29 '10 at 0:15
    
I'm looking for generic approaches to tuning PID controllers. Do you tune the P, I and D coefficients in a certain order? Do you have to form a closed system to tune or have you done it inside the game environment? –  tenpn Jul 29 '10 at 12:01

3 Answers 3

up vote 6 down vote accepted

There's actually a decent article in AI Game Programming Wisdom 2 by Euan Forrester regarding PID Controllers.

I'll just reiterate what he said about tuning the different coefficients:

  1. Start with the proportional coefficient (P) - This has the largest effect on the behaviour of the controller. Set the other 2 coeffs to 0 and tune P until you get a rough desired effect.
  2. Only vary one coefficient at a time - Get a decent feel for one coefficient to make sure it does approximately what it does while keeping the other 2 constant.
  3. Tune the coefficients in real time - The benefits are a bit obvious really. You don't want to recompile everything every time you make a change to a value, that's just common coding sense.
  4. (Optional) Have an instant replay feature in place - This will just help in case you observe something really weird happening with your PID values so you can replay the steps up until that point.

He also offers a number of online resources (some of which are dead links so I'll only post the ones that are still available):

Visual Loop Tuning

Tuning a PID Temperature Controller

Hope that helps

~Ray

share|improve this answer

Recent #AltDevBlogADay article describes PID controllers quite nicely, and the WebGL example on author's site can be useful for fine-tuning the variables.

share|improve this answer

For starters, Wikipedia actually has a good article on how to begin tuning. Without more details it's hard to go into more detail in a response.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.