Upload
others
View
4
Download
0
Embed Size (px)
Citation preview
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: Thermostat 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
CSE 466 Control 2
Controller is trying to balance sensor values on 4 sensors
Controlling a Simple System
Consider a simple system:
Scalar variables x and u, not vectors x and u. Assume effect of motor command 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.
( , )x F x u
0Fu
Action
StateChange in state “is a fn of”
Joint angle controller example
CSE 466 Control 4
State : joint angle
Action : motor command causes to change: 0
Sensor : joint angle encoderSet point : a target joint angle (or vector of angles)Linear restoring force / Quadratic error function
sprin
20
g like behaviorSpring Force Spring Energy 1 2( )F kx E x x
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:
Acceleration:
( ) ( , ) ( )x F u x x u x (x)
x xv
( , )x v
Fv u
x x u
v x u
Laws of Motion in Physics
Newton’s Law: F=ma or a=F/m.
But Aristotle said: Velocity, not acceleration, is proportional to the
force on a body. True in a friction-dominated setting
/x vv F m
x
The Bang-Bang Controller Push back, against the direction of the error
Error:
To prevent chatter around
Household thermostat. Simple but effective. PWM!
e x xset
0 : ( , ) 00 : ( , ) 0
e u on x F x one u off x F x off
::
e u one u off
e 0i.e., use small hysteresis , instead of0 as threshold
Bang-Bang Control
CSE 466 Control 9
Here, error is
e=xhuman – xrobotin some region close to the robot
Proportional Control Push back, proportional to the error.
Set ub so that For a linear system, exponential
convergence.
The controller gain k determines how quickly the system responds to error.
u ke ub
( , ) 0set bx F x u
x(t) Ce t xset
ub: bias action
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:
k is the controller gain.
( )cmd obs setv k v v
Velocity control
CSE 466 Control 13
Steady-State Offset
Suppose we have continuing disturbances:
The P-controller cannot stabilize at e = 0. Why not?
( , )x F x u d
Steady-State Offset
Suppose we have continuing disturbances:
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.
( , )x F x u d
Nonlinear P-control
Generalize proportional control to
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.
( ) bu f e u
Derivative Control
Damping friction is a force opposing motion, proportional to velocity.
Try to prevent overshoot by damping controller response.
Estimating a derivative from measurements is fragile, and amplifies noise.
P Du k e k e
Adaptive Control
Sometimes one controller isn’t enough. We need controllers at different time scales.
This can eliminate steady-state offset. Why?
u kPe ub
whereb I I Pu k e k k
Adaptive Control
Sometimes one controller isn’t enough. We need controllers at different time scales.
This can eliminate steady-state offset. Because the slower controller adapts ub.
u kPe ub
whereb I I Pu k e k k
Integral Control
The adaptive controller
Therefore
The Proportional-Integral (PI) Controller.
b Iu k e
0
( )t
b I bu t k edt u
0
( ) ( )t
P I bu t k e t k edt u
Integrate both sides wrt time
Proportional – Integral (PI) control
CSE 466 Control 21
The PID Controller
A weighted combination of Proportional, Integral, and Derivative terms.
The PID controller is the workhorse of the control industry. Tuning is non-trivial.
0
( ) ( ) ( )t
P I Du t k e t k edt k e t
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
CSE 466 Control 24
Proportional gain term
Integral and Derivative terms
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
Integral gain term Derivative gain term
PID Control Demohttps://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
whereset h h Px k e k k
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
CSE 466 Control 29
http://www.openservo.com/
Open Servo API
CSE 466 Control 30
API call DescriptionSet Position Set the position of the servoSet the servo address Configure the device address of the servo on the
TWI/I2C busConfigure PID Configure the servo response parametersServo specific configuration Configure servo max and min positions, as well as
deadband and reverse seekServo commands Send a command to the OpenServo to stop, start or
resetMotion Profiles Program the OpenServo to follow complex hermite
curvesR/C PWM Motion Run your OpenServo from an R/C controller
Open Servo PID configuration
CSE 466 Control 31
0x22 PID_PGAIN_HI PID proportional gain high byte0x23 PID_PGAIN_LO PID proportional gain low byte0x24 PID_DGAIN_HI PID derivative gain high byte0x25 PID_DGAIN_LO PID derivative gain low byte0x26 PID_IGAIN_HI PID integral gain high byte0x27 PID_IGAIN_LO PID integral gain low byte
End
CSE 466 Control 32