Basics of Control Based on slides by Benjamin Kuipers
How can an information system (like a micro-CONTROLLER, a fly-ball governor, or your brain) control the physical world? Examples:
You, walking down the street without falling over
A robot trying to keep a joint at a particular angle
A blimp trying to maintain a particular heading despite air movement in the room
A robot finger trying to maintain a particular distance from an object
CSE 466 Control 1 A controller
Controller is trying to balance sensor values on 4 sensors
CSE 466 Control 2 Controlling a Simple System “is a fn of” Change in state State Consider a simple system: xFxu (,) Action
Scalar variables x and u, not vectors x and u. Assume effect of motor command u: F 0 u The setpoint xset is the desired value. The controller responds to error: e = x xset
The goal is to set u to reach e = 0. Joint angle controller example
State : joint angle Action : motor command causes to change: 0
Sensor : joint angle encoder Set point : a target joint angle (or vector of angles) Linear restoring force / Quadratic error function spring like behavior 2 Spring Force F kx Spring Energy E 1 2( x x0 )
CSE 466 Control 4 The intuition behind control
Use action u to push back toward error e = 0
What does pushing back do?
Position vs velocity versus acceleration control How much should we push back?
What does the magnitude of u depend on? Velocity or acceleration control?
Velocity: xxu ()xF (, ) () u x (x)
Acceleration: xv xxu F(, ) vu x x v vxu Laws of Motion in Physics
Newton’s Law: F=ma or a=F/m. xv x vFm /
But Aristotle said:
Velocity, not acceleration, is proportional to the force on a body.
True in a friction-dominated setting The Bang-Bang Controller Push back, against the direction of the error
e x xset Error: euonxFxon0: (,)0 e0: u off x F (,)0 x off
To prevent chatter around e 0 euon : i.e., use small hysteresis , instead of euoff : 0 as threshold
Household thermostat. Simple but effective. PWM! Bang-Bang Control
Here, error is
e=xhuman –xrobot in some region close to the robot
CSE 466 Control 9 Proportional Control
Push back, proportional to the error.
ub: bias action u ke ub Set ub so that xFxu (,)0set b For a linear system, exponential convergence. t x(t) Ce xset The controller gain k determines how quickly the system responds to error. Proportional control (discrete time)
CSE 466 Control 11 Velocity Control
You want the robot to move at velocity vset.
You command velocity vcmd.
You observe velocity vobs.
Define a first-order controller:
vkvvcmd () obs set
k is the controller gain. Velocity control
CSE 466 Control 13 Steady-State Offset
Suppose we have continuing disturbances: x Fxu(,) d
The P-controller cannot stabilize at e = 0.
Why not? Steady-State Offset
Suppose we have continuing disturbances: x Fxu(,) d
The P-controller cannot stabilize at e = 0.
If ub is defined so F(xset,ub) = 0
then F(xset,ub) + d 0, so the system is unstable
Must adapt ub to different disturbances d. Nonlinear P-control
Generalize proportional control to
ufeu () b
Nonlinear control laws have advantages
f has vertical asymptote: bounded error e
f has horizontal asymptote: bounded effort u
Possible to converge in finite time.
Nonlinearity allows more kinds of composition. Derivative Control
Damping friction is a force opposing motion, proportional to velocity. Try to prevent overshoot by damping controller response.
ukekePD Estimating a derivative from measurements is fragile, and amplifies noise. Adaptive Control
Sometimes one controller isn’t enough. We need controllers at different time scales.
u kPe ub
ukebIwhere kk IP This can eliminate steady-state offset.
Why? Adaptive Control
Sometimes one controller isn’t enough. We need controllers at different time scales.
u kPe ub
ukebIwhere kk IP This can eliminate steady-state offset.
Because the slower controller adapts ub. Integral Control
The adaptive controller ukebI
t Integrate both sides wrt time Therefore ut() k edtu bI b 0
The Proportional-Integral (PI) Controller.
t ut() k et () k edt u P Ib 0 Proportional – Integral (PI) control
CSE 466 Control 21 The PID Controller
A weighted combination of Proportional, Integral, and Derivative terms. t ut() k et () k edt k et () PI D 0 The PID controller is the workhorse of the control industry. Tuning is non-trivial. PID controller
CSE 466 Control 23 Tuning
PID properties to consider Rise time Overshoot Settling time Steady-state error Stability
Many PID tuning methods exist Proportional gain term
CSE 466 Control 24 Integral and Derivative terms
Integral gain term Derivative gain term
Question from class: the integral of the red trace on the left is non-zero. Yet the controller is converging to the setpoint. Is there a decay mechanisms for the I term? A: not necessarily. In this example system, a non-zero bias command may be necessary to keep the system at its setpoint. Think of an application like gravity compensation: to keep the joint still, you may have to apply a constant force to counteract gravity. The integral term can find that bias point.
CSE 466 Control 25 PID Control Demo https://sites.google.com/site/fpgaandco/pid
CSE 466 Control 26 Habituation
Integral control adapts the bias term ub.
Habituation adapts the setpoint xset. It prevents situations where too much control action would be dangerous. Both adaptations reduce steady-state error.
u kPe ub
xkekkset hwhere h P Other control techniques
Feedback control Sense error, determine control response. Feedforward control Sense disturbance, predict resulting error, respond to predicted error before it happens. Optimal control Optimize some sort of cost (e.g. actuation energy) Linear Quadratic Gaussian Control (LQC) Model-predictive control Plan trajectory to reach goal. Take first step. Repeat. Combines benefits of planning & control See Emo Todorov’s ping pong ball juggling robot “Intelligent control” Use machine learning, planning May learn system dynamics (state, action state) Even with the model learned, you may need to do planning to find a sequence of actions that gets you to the goal state Culturally more CS than EE Tends to use more complex data structures Less amenable to mathematical analysis Example PID controller --- OpenServo Servomotor controller
High performance AVR 8-bit microcontroller Compact H-Bridge with high performance MOSFETs Precision control over servo position and speed I2C/TWI based interface for control and feedback Feedback of position, speed, voltage and power Advanced curve based motion profile support EEPROM storage of servo configuration information Software written in C using free development tools I2C/TWI bootloader and GUI programmer http://www.openservo.com/
CSE 466 Control 29 Open Servo API
API call Description Set Position Set the position of the servo Set the servo address Configure the device address of the servo on the TWI/I2C bus Configure PID Configure the servo response parameters Servo specific configuration Configure servo max and min positions, as well as deadband and reverse seek Servo commands Send a command to the OpenServo to stop, start or reset Motion Profiles Program the OpenServo to follow complex hermite curves R/C PWM Motion Run your OpenServo from an R/C controller
CSE 466 Control 30 Open Servo PID configuration
0x22 PID_PGAIN_HI PID proportional gain high byte 0x23 PID_PGAIN_LO PID proportional gain low byte 0x24 PID_DGAIN_HI PID derivative gain high byte 0x25 PID_DGAIN_LO PID derivative gain low byte 0x26 PID_IGAIN_HI PID integral gain high byte 0x27 PID_IGAIN_LO PID integral gain low byte
CSE 466 Control 31 End
CSE 466 Control 32