PID Controls
Howie Choset
(thanks to George Kantor and Wikipedia) http://www.library.cmu.edu/ctms/ctms/examples/motor/motor.htm
Overview
• Mass-Spring-Damper System
• Second order ODE
– Definition
– Vary parameters
– Forcing functions
• Different feedback meaning
– Proportional
– Derivative
• Control for Error – block diagram
• Integral Control
• Different Affects of Varying PID
• Feed Forward Term
• Vehicle Controls
Mass Spring
Standard Form of DEQ
Natural (undamped) frequency (rads/sec)
Damping ratio (unitless)
Vary Natural Frequency
Mass Spring Damper
Standard Form of DEQ
Natural (undamped) frequency (rads/sec)
Damping ratio (unitless)
Let
Solutions/Responses
Under-damped (0 < < 1)
Let
Solutions/Responses
Under-damped (0 < < 1)
Let
Solutions/Responses
Under-damped (0 < < 1) decay Oscillation, damped natural frequency
Let
Step Response
,
As time goes on, x(t) goes to 1
Open Loop Controller controller tells your system to do something, but doesn’t use the results of that action to verify the results or modify the commands to see that the job is done properly
Open Loop Controller
Plant controller tells your system to do something, but doesn’t use the results of that action to verify the results or modify the commands to see that the job is done properly
Open Loop Controller
Plant Output controller tells your system to do something, but doesn’t use the results of that action to verify the results or modify the commands to see that the job is done properly
Closed Loop Controller
Give it a velocity command
and get a velocity output
Controller Evaluation
Steady State Error
Rise Time (to get to ~90%)
Overshoot
Settling Time (Ring) (time to steady state)
Stability
Ref +
error
Controller voltage
Plant
PID Feedback
-
P Feedback
-Kx
( + K) x = 0
It is like changing the spring constant
Proportional Feedback plant
Set desired position to zero
Note that the oscillation dies out at approximately the same rate but has higher frequency. This can be thought of as “stiffening the spring”.
Proportional/Damping plant
We can increase the damping (i.e., increase the rate at which the oscillation dies out)
Increasing damping slows everything down (note deriv is an approx and turning the gain high, can cause problems because in a sense it amplifies noise)
PD works well if desired point is an equilibrium of system, which makes sense because when you are at target, PD does not exert force
Non-zero desired PD
X d
= 1.6
Settle time same
Steady state error!
At set point, applying no force so end up settling at equilibrium that balances force due to error and force due to spring (damper goes away in steady state because depends on derivative).
Crank up P gain, steady state error gets smaller, but that causes overshoot, oscillations, etc which you don’t want
PID Control plant
System does its dynamic thing and then gradually integrates to correct for steady state error
As increase I gain, gets faster, good response
Integral gets so bad, it starts to interfere with other dynamics, lead to unintended motions which could lead to instability
Closed Loop Response (Proportional Feedback)
Proportional Control
K p
Easy to implement
Input/Output units agree
Improved rise time
Steady State Error (true)
P: Rise Time vs.
Overshoot*
P: Rise Time vs . Settling time*
P: Steady state error vs . other problems
R +
error
Controller voltage
Plant
Voltage = K p
error
*In some other systems, not mass-spring
Closed Loop Response (PI Feedback)
Proportional/Integral Control
No Steady State Error
K p
1 s
K
I
Bigger Overshoot and Settling
Saturate counters/op-amps
P: Rise Time vs.
Overshoot
P: Rise Time vs . Settling time
I: Steady State Error vs . Overshoot
Ref +
error
K p
1 s
K
I voltage
Plant
Voltage = (K p
+1/s K i
) error
Closed Loop Response (PID Feedback)
Proportional/Integral/Differential
Quick response
Reduced Overshoot
K p
1 s
K
I
sK
D
Sensitive to high frequency noise
Hard to tune
P: Rise Time vs.
Overshoot
P: Rise Time vs . Settling time
I: Steady State Error vs . Overshoot
D: Overshoot vs. Steady State Error
R +
error
K p
1 s
K
I
sK
D voltage
Plant
Voltage = (K p
+1/s K i
+ sK d
) error
PID Controller Block Diagram
Quick and Dirty Tuning
• Tune P to get the rise time you want
• Tune D to get the setting time you want
• Tune I to get rid of steady state error
• Repeat
• More rigorous methods – Ziegler Nichols, Selftuning,
• Scary thing happen when you introduce the I term
– Wind up (example with brick wall)
– Instability around set point
Feed Forward
Decouples Damping from PID
Volt
To compute
K b
Try different open loop inputs and measure output velocities
For each trial i,
Tweak from there.
K b i u
.
i i
, K b
avg K b i
K
R +
K b
error
Controller
+
+ volt
Plant
Assumptions
• planar workspace
• position of robot and goal are known
• omni-directional robot (we’ll relax this later)
• control input is velocity:
(boldface lie, we’ll relax this later, too)
Proportional (P) Control:
• the equation above is called a control law
• kp is called the proportional gain
• kp is a tunable parameter
• physically, kp is the stiffness of the spring
Proportional-Derivative (PD) control:
Fill the world with honey!
In direction of arrow opposite
• k d
is called the derivative gain
• k p
and k d
are tunable parameters
• physically, kd is the damping term
• all of the stuff about P control still applies
Robot Inputs
So far we’ve assumed something like
But really, we control the velocities of the left and right wheels, which can easily be mapped to forward and turning velocities:
Nonholonomic Constraints
The equations of motion using these controls are:
The fact that the robot can’t move sideways is a nonholonomic constraint (we will see this again).
The Problem:
P or PD control won’t work.
No smooth control law will!
A Simple Solution:
Like a rigid trailor hitch (not driving to point)
A Simple Solution (cont.):
If we ignore orientation: so we can implement the PD control law as: p p
Did not get rid of nh constraint, but moved it to something we don’t care about
(theta, angular and linear velocities) - trailor hitch story
Follow a straight line with differential drive or at least get to a point
Error can be difference in wheel velocities or accrued distances
Make both wheels spin the same speed asynchronous – false start wheels can have slight differences (radius, etc)
Make sure both wheels spin the same amount and speed false start
Line following
More complicated control laws – track orientation
m1vref = vref + K1 * thetaerror + K2 * offset error
m2vref = vref - K1 * thetaerror - K2 * offset error offset
Really, there is a sensor
Encoders
Encoders – Incremental
Photodetector
Encoder disk
LED Photoemitter
Encoders - Incremental
Encoders - Incremental
• Quadrature (resolution enhancing)
Where are we?
• If we know our encoder values after the motion, do we know where we are?
Where are we?
• If we know our encoder values after the motion, do we know where we are?
• Integration?
Where are we?
• If we know our encoder values after the motion, do we know where we are?
• What about error?
Problems With Dead Reckoning
Wheel slip and gear slop
Drift error accumulates over time
Gives only local relative position
Accelerometers
Voltage between fingers is proportional to spring displacement
Solve for acceleration
Subtract gravity
Integrate to find velocity
Integrate again to find position
Proof
Mass d2 d1
Fixed fingers
Moving finger
Suspension
Springs
F = ma (Newton)
F = -kx (Hooke)
Problems With Accelerometers
Integration error leads to drift
Requires very high data-rate and integration loop
Sensitive to vibration and bumps
Gyroscopes
The wheel doesn't rotate, the robot does
Measure the angle of each gimbal ring to give orientation
MEMS gyroscopes work differently
Maps
Google has images of almost the whole world with road network information
Buildings have blueprints
In many cases, a robot will know its environment in advance
Two types of maps
Landmark
Pixel grids
Landmark Maps
List of x,y coordinates
Unique landmarks
Sensor determines direction and/or distance to landmark
Grid Maps
Represented as a matrix
Each pixel is either an obstacle or not
Sensor determines distance to an obstacle
Map Based Localization
Observe distance and angle to landmark with known position
Requires map
Sensors:
Sonar
Lidar
Cameras
Ranging Sensors
Estimate distance to an obstacle
Supersonic Sonar
Strange pattern
Minimum distance
Lidar
Fire IR laser and time reflection
Spin a mirror to produce a 2D ray
Pan or spin the lidar to produce 3D scans
Can match with camera for colorization
$5,000
• Maps
To be continued
• Bayesian Localization