- 1. PID
- 2. math/pysics has many equations describing the real world, they seem very precise
- 3. lets say we want to program a car's cruise control to drive at exactly 35mph
- 4. what happens when anything changes?
- 5. Real Wold
- 6. Error. Here in the real world we have
- 7. Step 0 Bang-Bang
- 8. Step 1. add some P
- 9. When P is not enough
- 10. Introducing I
- 11. P + I controllers
- 12. D controllers
- 13. Resources
- say very specifically we want to be able to climb into a specific car and know exactly how far we need to push the accellerator to go 35mph on a specific road under controlled conditions
- what do we need to know?
- weight of the car
- power output of engine
- incline/decline
- aeodynamic drag
- map of power at each point of accellerator's position
- altitude (affects aerodynamics)
- wind
- friction of tires ( inflation level, tread wear, road composition)
- now calculate the drag, friction, inertia of car determine exact power needed
- Tada!
- disaster
- any drivers in the room? do you do any of this to drive at a set speed? No.
- what do we do?
- glance at the speedometer and press harder or lighter on the accellerator. Maybe even the brakes.
- Repeat until you're driving the right speed
- is that hard? no
- does it take a long time to learn this in a new car? no.
- can robots drive this way? yes.
- what we want (travel at 35 mph)
- what actually is (traveling at 0mph)
- the difference is what we will call the error
- to get what we want we want to minimize the error, idealy go to zero.
- if we're going too slow, 100% throttle
- if we're going too fast, 0% throttle
- This is called a Bang-Bang controller.
- it works! (kinda)
- can we do better? yes.
- bang-bang controllers are sometimes all you need. Shooter flywheel speed for example.
-
what if instead of just 100% or 0% throttle, we adjust our throttle according to how far off we are from our desired speed?
-
P stands for proportional
-
Units? how to translate 35mph to slow into 20% throttle?
error = desiredspeed - currentspeed
Trottle = P * error
P = ???
-
We have no idea what P should be. What happens if we guess?
-
P = 10
Throttle = Min(1.0, P * error) # throttle can't go over 100%
any error over 0.1 mph will result in full or zero throttle, essentially a bang-bang controller
-
P = 1
any error over 1 mph will result in full or zero throttle, better.
-
P = 0.1 ?
any error over 10mph will result in full or zero throttle. errors in between result in moderation in the throttle.
This might work!
We don't even need to know if the driver had breakfast.
-
-
what happens if conditions change a little?
- we're going uphill, downhill
- we put premium unleaded in the tank this week
- the system adapts, and keeps applying more Throttle until we reach the correct speed
-
what if we change something big? new motor? pull a trailer?
- might keep working
- need to test it, what was ballance before might not be anymore or else we'd use the same P value for all speed controllers
- Undershooting and overshooting the goal
- Sometimes P will overshoot and occilate
- Sometimes P doesn't provide enought "umph" to get us all the way to our goal, or it can take a long time.
- can we do better? Yes.
-
I is for Integral
-
remeber we used the current error times our P value for our proportional controller
-
I uses the total history of past errors
-
Now we have to keep track of errortotal, all the errors we've seen.
-
In calculus this would be a continuous function, however we're doing descrete calculations, say every 20ms or so
-
totalerror = totalpreviouserror + currenterror
- - This is the area under the curve - (This will be become more clear once you've taken Calculus)
K for "Kostant"
Throttle = Ki * totalerror
- what does this do? If our controller get's stuck, the accumulated error pushes us towards the right throttle.
- don't use just I controllers
- P controllers are pretty good by themselves
- I element can help speed up when we're far off the target and give that final nudge when P can't finish the job
- <graph comparing, P, I, and P +I>