5 ms·
I've used PID controllers for some things in game development, but mostly for simple stuff like specifying a target velocity. What I always have problems with,
by zubspace 5y ago
I've used PID controllers for some things in game development, but mostly for simple stuff like specifying a target velocity.
What I always have problems with, is using pid controllers for angular movements. Like turning an object to a desired angle or approaching a desired angular velocity. Are PID controllers suited for this task? For example: You want to turn right and specify a large angular velocity. But now, after a few turns the integral part adds up to a huge value. Then you want to turn back, but now the response is very slow, because of the large integral part. Never got around this problem. How would you approach this?
- meheleventyone 5y agoPID controllers are used to do exactly this with quadcopters. There is a lot of finesse on top to deal with oddities and problems like I term windup. Common ones are zeroing it out when it’s no longer valid or clamping it within specific bounds. For games you might just get away with a PD controller and not need to worry about the I term at all.
- leafario2 5y ago1) this is the same problem like controlling the angle of a quad copter, for which I have used PID. You can calculate the error of the position, which is in the range -180..179. Applying one PID stage to the error of the orientation yields a "desired rate of change" - it increases if the error is large or held for a long time and it's sign describes the direction of the rate of change of orientation. You can use another PID stage to give a step count power iteration (how much to turn the object). 2) integral windup is commonly prevented by just capping it. You can also use a smoother capping function which bounds the size of the integral, or lowers it on each iteration.
- zubspace 5y agoCapping and/or gradually lowering the the integral part seems like an elegant solution. Thanks for your input! This is something which is never told but should be part of every PID controller resource on the web.
- jstanley 5y agoAn alternative to capping is to avoid adding anything to the integral term in situations where the actuator is already at 0% or 100% of the possible range.