Brett Browning and M. Bernardine Diasbrettb/16-362/lectures/16362_Lecture6.pdfachieve the desired...
Transcript of Brett Browning and M. Bernardine Diasbrettb/16-362/lectures/16362_Lecture6.pdfachieve the desired...
Lab #1 feedbackLab #1 feedbackFinal project overview
Final project teamsFinal project teamsLab #2 overview
Slide 2Slide 2
Cluttered racing taskProbably want to be able to accelerate fast, brake fast, turn quickly
Reduce mass (better power to weight)Lower Center of GravityReduce rotational inertia (bring mass close to CG)( g )
SensingEnsuring that your sensors can see the “interesting” bits for the task is essentialE.g. where should lasers be, where should they aim?E.g. where should lasers be, where should they aim?
ProtectionEnsuring that computers/sensors can’t be damaged is a good ideaAlways remember wires in a layout
AccessibilityAccessibilityBeing able to access all the parts is very useful
Slide 3Slide 3
Hopefully you learned toBe prepared and on time for the demoMake sure it all works for the demoStart early, have a plan, re-evaluate as you proceed
DrivingDrivingRamping up/down speeds is crucial to controlEncoders are good, but may have calibration issuesSensor is good, but doesn’t see everything
PlottiPlottingLearn to use Matlab (initial pain, but very useful)Save data in text files:
one sample per row, space or comma separated e.g.p p p p g1.3654 3.3 4.56781.4663 3.5 4.222
Load with matlab:data=load(‘foo.txt’);
Slide 4Slide 4
Introduction to controlClosed-loop controlPID controlER1 controlER1 controlDrive to a pointPath followinggNext…
Slide 8Slide 8
Detailed topic, but we’ll just focus on PID Detailed topic, but we ll just focus on PID controlWe won’t be concerned with detailed analysisanalysis
There are many books on the topic if you are interested!Al o a co e (e TAMUQ CMU P )Also many courses (e.g. TAMUQ, CMU-P…)
Key conceptsOpen loop vs closed (feedback) loop controlInput vs. ResponsePID controlRules of thumb for tuning PID loops
Slide 9Slide 9
How to correct the command to achieve How to correct the command to achieve target?E g Turn to pointE.g. Turn to point
θω
θ
Slide 10Slide 10
Generate a command (or sequence) to Generate a command (or sequence) to achieve the desired trajectoryNo feedback based on outcomeNo feedback based on outcome
Path planning is often done this p gway: have a model of how
system will respond, pick the best command, then execute
Slide 11Slide 11
What can go wrong?
Generate a command (or sequence) to Generate a command (or sequence) to achieve the desired trajectory and adjust it based on sensed feedback it based on sensed feedback
Velocity control can be done this way, same for steering or visual servoing:same for steering or visual servoing:
See where we are and adjust based on our observed “error”
Slide 12Slide 12
What can go wrong?
Give an input measure the outputGive an input, measure the output
Input Response
robot
vcmd Linear speed
p
robot
tStep input tUsually calledStep input tUsually called the plant
If we knew the system response we could
Slide 13Slide 13
y pinvert it to find the best command
Overshoot
** Multiple ways to define rise time
Input
Overshoot
Ringing (non shown)
Steady state error
OutputRise time**
Steady State Response
Transitory Response
Settling time
tSettling time
Typical control problem: For given input design
Slide 16Slide 16
Typical control problem: For given input design system to achieve target response outputs
Add feedback path and use error as inputAdd feedback path and use error as input
ErrorCommand/in
Robot(or plant)
vcmd(t) Sensed output+ e(t)
oCo a d/put
-
Actualvact(t)
Slide 17Slide 17
Add feedback path and use error as inputAdd feedback path and use error as input
ErrorCommand/in
Robot(or plant)vcmd(t)
Sensed Output
+Controller
e(t)
ErrorCommand/input
( p )-
Actualvact(t) Actual
Slide 18Slide 18
Command is function of error and its Command is function of error and its integral/derivatives
Proportional, Integral, Derivative
In discrete time:
Robotvcmd(t)Sensed Output
+
-Controller
e(t)
Slide 19Slide 19
-vact(t)
Command is function of error and its Command is function of error and its integral/derivatives
Proportional, Integral, DerivativeI DP I D
In discrete time:
Robotvcmd(t)Sensed Output
+
-Controller
e(t)
Slide 20Slide 20
-vact(t)
Typical responseTypical responseSmaller Kp
Underdamped
OutputInput
L KLarger KpOverdamped
t
Slide 21Slide 21
PIDControl(Kp,Ki,Kd,deltat):ierr=0elast=0hil (1) {while (1) {
vdesired = get_new_command()vactual = sense_output()
err = vdesired-vactualierr += err*deltatderr = (err-elast)/deltatelast = errelast = err
vcmd = Kp*err + Ki*ierr + Kd*derr}
Slide 22Slide 22
1 Check open loop response1. Check open loop response2. Tune Kp to get okay performance (Ki=Kd=0)3. Tune Ki to get zero S.S. Errorg4. Tune Kd to reduce overshoot and improve
rise-time response5. Micro-tune Kp, Ki, Kd until target achieved
Tuning by hand is an art. Mathematical derivation is better for serious vehicles.
Slide 23Slide 23
ER1 ControllerER1 ControllerRuns PID on (scaled) robot speed and rotation, with commands (vn,van)Returns encoder counts on left and right wheels (n n )Returns encoder counts on left and right wheels (nr, nl)
Robot_server (C++)Performs translation from (v,w) to commands (vn,van)
f i ( θ)Performs dead reckoning to return (x,y,θ)
vω
Aligned with robot
(x,y)
Slide 24Slide 24
θ
gstart position
javaER1
LidarServer Robot*Main
javaER1
UDPShared
MemoryUDP
Netserver
RobotServer
ER1 Controller
BShell
er1_stereo
• 2xDC Motors
Run remotely via ssh
Slide 25Slide 25
• 2xOptical encoders, 512 CPR• Lead-acid battery
Xdriver
Goal: Goal: Given target goal point, drive to it
How do we do this?How do we do this?Driving arcsPIDPIDTrapezoidal control
Slide 26Slide 26
Given a path how do we stay on the Given a path, how do we stay on the path?
Carrot following and Pure pursuitCarrot following and Pure pursuitPID on headingDual controllerDual controller
Slide 27Slide 27
Pick a point ahead on the path and Pick a point ahead on the path and execute drive to point
How to pick the point? How far ahead? How to pick the point? How far ahead? How to drive to point? Heading error?
Closest point on path
Intersection with circle
L
Slide 28Slide 28
with circle radius L
Circle intersection with pathCircle intersection with pathDrive a circular arc to intersect the point
Driving Arc, radius r
Intersection with circle
Slide 29Slide 29
with circle
Circle intersection with pathCircle intersection with pathDrive a circular arc to intersect the point
Driving Arc, radius r
Intersection with circle L
curvature
Slide 30Slide 30
with circle L
Given v calculate w (some prefer Given v, calculate w (some prefer curvature so invert accordingly)
Driving Arc, radius r
Intersection with circle L
Note, sign takes care of left vs right turn
Slide 31Slide 31
with circle L
Variations: Variations: Run a PID loop on target vGeneralize eqn to PID loopGeneralize eqn to PID loop
Driving Arc, radius r
Intersection with circle L
Proportional control, can also add integral,
derivative…
Slide 32Slide 32
with circle L
May care about heading error when we May care about heading error when we reach the path
Run a PID on heading errorOr, combine with pure pursuitCan get very creative but need to tune to vehicle and environmentvehicle and environment
Heading errorPure pursuit Heading error
Slide 33Slide 33
errorp Heading error