In this cruise control case study, you can use Pylab and the SciPy function lsim() to evaluate the cruise control performance with a 4 percent grade. Note that a grade of 4 percent means rise over run of 4/100, which is equivalent to

Set T = 10 s, vmax = 120 mph and v0 = 75 mph. Units conversion is handled inside cruise_control(). The loop damping factor is

(critically damped, meaning the closed-loop poles are repeated on the negative real axis, and ωn takes on values of 0.5, 0.1, and 0.2 rad/s).
In [<b>241</b>]: t = arange(0,100,.01) In [<b>242</b>]: b,a = ssd.cruise_control(0.05,1.0,10.,75.,120.,'HED') In [<b>243</b>]: tv,v,xs = signal.lsim((b,a),0.04*ones(len(t)),t) In [<b>245</b>]: plot(tv,v) In [<b>247</b>]: # similarly for wn = 0.1 and 0.2
Velocity error results can be found in the following figure.
![[Credit: Illustration by Mark Wickert, PhD]](https://cdn.prod.website-files.com/6634a8f8dd9b2a63c9e6be83/669d580141f2e6ebd7d638a5_379685.image2.jpeg)
You see that at hill onset the vehicle velocity error begins to rise, meaning the actual vehicle velocity is falling below the set point value. Over time, the cruise control responds increasing the throttle setting to correct for the hill disturbance, and the velocity error drops to zero. If you increase ωn the control loop response time decreases, thereby lowering the velocity error when the 4 percent grade onset occurs.