PID Controllers in Unity3D (2021)
41–46 of 46 posts
Re: PID Controllers in Unity3D (2021)
#42I once used a $25 off-the-shelf PID temp controller that came with a type K thermocouple and integrated 12v control line to build an air intake regulator for my meat smoker. I couldn't believe the outcome - 3 hours of fuel turned into 11 hours, and the (logged) temperature stayed between 118.4 and 122 degrees celsius for 10 hours of that. This was outdoors, with all the variance that comes with it, and all I did was…
Re: PID Controllers in Unity3D (2021)
#43Earlier quoted context omitted.
The D term is complicated. Where you do you get the derivative? If you have to differentiate the input, and there is noise, the raw derivative will have huge variations. Then you need a low pass filter before the differentiator. This introduces lag. So you now have both D gain and filter frequency to tune. See any classical control theory book for the theory on this.
Even when tuning PID loops for chemical plants as a controls engineer, myself and my colleagues (across multiple companies) generally just set the D term to zero. If the D term (derivative) was needed, tuning that one loop would often be assigned a whole formal project by itself. When I hear people say "PID loop" I almost always subconsciously translate it to hear "PI loop" in my head unless there's evidence that it'…
When the rocket had an angle error it needed to point it's thrust to rotate itself back to 0. There is no built in stopping force that stops the rocket rotating when the thrust is not angled. So a D term was needed in order to take into account how fast the rotation was happening. When it was rotating to 0 degrees of error, it needed that d term to not overshoot. With the d term, the thrust would swing in the opposite direction to prevent it overshooting.
Re: PID Controllers in Unity3D (2021)
#44Earlier quoted context omitted.
Maybe I'm misunderstanding something, but wouldn't you still want/need a D term unless you have a system with a nearly instant response? I'd think that even if you stop applying a delta the second you hit the set-point, if you've built up non-trivial inertia, then you'll overshoot the target fairly significantly?
Everyone will say "depends on the system" but generally the D term is not only not needed, but typically considered counter-productive or even against best practices. PI-loops tend to be much more stable than PID-loops and far easier to successfully tune for an acceptable response. You do get overshoot with a decently tuned PI-loop, but it's not enough to cause problems. A bit of overshoot doesn't tend to hurt anythi…
With a heater,once you get to zero error, any overshoot will reduce back the opposite way because heat is always lost.
Re: PID Controllers in Unity3D (2021)
#45My favorite use of a PID controller in Unity was to act as a camera operator for a VR football game. We used cameras for the screen-display (we could either show you the VR player's perspective, or one of several cameras), and for the jumbotron in the stadium. This ended up being really cool for downfield throws. When you bombed the ball 45 yards to a receiver, it could be a little hard to see the action. It was real…
Wouldn't it be better to model imperfections separately rather than rely on PID oscillations? I can see how this can easily fail and cause some dramatic and unnatural camera movements.
It was, like, 15 minutes of work to find a range of acceptable PID values, then generate a random variable from a normal distribution with a mean at the expected value (we just hard-trimmed the random value at 1 std deviation, because we didn't want a 99th percentile result to cause craziness).
Other than the hilarity that ensued while I was playing around with PID values to find the acceptable ranges, I can't recall ever seeing a bug that was problematic from this, so I didn't really give it much thought. Honestly, there were much bigger things to work on.
The nice thing about this system though, is it created "personality" for the camera. If a virtual camera operator had a lower D-value, they'd overshoot just a little bit, semi-consistently. Another one might have a slightly lower I-value, and end up just a little bit further back in the tracking.
It was a super quick way to give a little bit of organic variance to the camera operation, so it didn't feel "samey" every time.
Re: PID Controllers in Unity3D (2021)
#46A thermostat is not an on/off-controller but a proportional controller. The lower the temperature, the higher the flow rate. At least for thermostatic radiator valves this is true.
FWIW everywhere I've lived has an on/off thermostat, maybe it's regional