-
Notifications
You must be signed in to change notification settings - Fork 0
/
PID_control.py
792 lines (645 loc) · 27 KB
/
PID_control.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
#!/bin/python
#
# PID control for inverted pendulum. Control is implemented as a class,
# such that other systems/ODE can be controlled without much additional
# effort.
# Several phenomena present in real world control applications are also
# implemented, such as bounded maximal control, limited controller
# speed and limited access to system variables. A random, but constant
# noise perturbes the system.
#
# Further features include the possibility to switch between linearized
# and non-linear pendulum and an optimization algorithm for optimal
# control parameters with respect to multiple optimality criteria.
#
# For debugging and testing purposes, use the file debug.py!
#
# Author: Philipp Schuette
# License: GPL-3.0
# Date: 20/04/2019
import matplotlib.pyplot as plt
import numpy as np
from matplotlib import animation
##################
# PID Controller #
##################
class PIDControl():
"""
Class implementation of a PID controller. This class is initialize
from given data like parameters for P, I and D, controller speed
with respect to the modelled system and a bound for controller
ouput. Especially the latter two are quite important in practical
applications. The set point, that the controller tries to reach,
can also be adjusted manually. A parameter deadband reduces strain
on possible machinery behind the controller; the control output is
only changed, if the newly calculated output differs from the
previous one by at least the amount specified by deadband.
"""
def __init__(self, alpha, beta, mu, frequency,
max_control, set_point, deadband):
"""
Initialize PIDControl class.
:type alpha: float > 0
:param alpha: proportional control parameter
:type beta: float > 0
:param beta: derivative control parameter
:type mu: float > 0
:param mu: integral control parameter
:type frequency: int >= 1
:param frequency: controller speed parameter
:type max_control: float > 0
:param max_control: controller output bound
:type set_point: float between 0 and 2*pi
:param set_point: desired valued of controlled system
:type deadband: float > 0
:param deadband: minimum difference for controller adjustment
>>> import numpy as np; from PID_control import *
>>> ALPHA = 4.4; BETA = 2.0; MU = 1.2; MAX_CONTROL = 2.6
>>> FREQUENCY = 30; DEADBAND = 0.01; SET_POINT = -0.0*np.pi
>>> controller = PIDControl(
... ALPHA, BETA, MU, FREQUENCY, MAX_CONTROL, SET_POINT, DEADBAND
... )
>>> print(controller)
PID Controller with alpha = 4.4, beta = 2.0, mu = 1.2
"""
self.alpha = alpha
self.beta = beta
self.mu = mu
self.frequency = frequency
self.max_control = max_control
self.set_point = set_point
self.deadband = deadband
# Attribute to memorize the previous or latest change in controller
# output:
self.output = 0
# Attribute to memorize the integral control value up to the current
# time:
self.integral = 0
# Attribute to keep track of controller speed:
self.action = 0
def __repr__(self):
"""
Return string representation of PID controller.
"""
return("PID Controller with alpha = {}, beta = {}, mu = {}".format(
self.alpha, self.beta, self.mu
))
def total_output(self, x1, x2, t1, t2, precision=4):
"""
Method returning the total controller output in response to system
value x at time t. The output is bounded by the max_control attribute
and controller adjustment speed is bounded by the frequency attribute.
Controller does not adjust, if successive outputs differ by less than
the deadband attribute. Limited measurement precision is included by
rounding controller input.
:type x1: float
:param x1: system value at time t1
:type x2: float
:param x2: system value at time t2
:type t1: float
:param t1: last time point
:type t2: float
:param t2: current time point
:type precision: int > 0
:param precision: system measurement precision
:output: total control value
"""
if (self.action == 0):
control_value = (
self.proportional_output(np.round(x2, precision), t2)
+ self.derivative_output(np.round(x1, precision),
np.round(x2, precision), t1, t2)
+ self.integral_output(np.round(x1, precision),
np.round(x2, precision), t1, t2)
)
if (np.abs(control_value - self.output) >= self.deadband):
if (control_value > self.max_control):
self.output = self.max_control
elif (control_value < -self.max_control):
self.output = -self.max_control
else:
self.output = control_value
self.action = (self.action + 1) % self.frequency
return(self.output)
def proportional_output(self, x, t):
"""
Method returning the proportional or I controller output, depending on
the controller attribute alpha.
:type x: float
:param x: system value at time t
:type t: float
:param t: current time point
:output: Proportional control value
"""
control_value = -self.alpha * (x - self.set_point)
return(control_value)
def derivative_output(self, x1, x2, t1, t2):
"""
Method returning the derivative or D controller output, depending
on the attribute beta. A numerical approximation of the
derivative value is necessary to compute the ouput. The
trapezoid rule was chosen for that.
:type x1: float
:param x1: system value at time t1
:type x2: float
:param x2: system value at time t2
:type t1: float
:param t1: last time point
:type t2: float
:param t2: current time point
:output: derivative control value
"""
control_value = -self.beta*(x2 - x1)/(t2 - t1)
return(control_value)
def integral_output(self, x1, x2, t1, t2):
"""
Method returning the integral or I controller output, depending on the
controller attribute mu. A numerical approximation of the integral
value is necessary to compute the output.
:type x1: float
:param x1: system value at time t1
:type x2: float
:param x2: system value at time t2
:type t1: float
:param t1: last time point
:type t2: float
:param t2: current time point
:output: integral control value
"""
control_value = (self.integral - self.mu*(t2 - t1)
* (x1 - self.set_point + x2 - self.set_point)/2.0)
self.integral = control_value
return(control_value)
##################################
# Controlled Pendulum ODE Solver #
##################################
class Pendulum():
"""
Class implementation of a simple ODE solver for the inverted pendulum.
Intended to be used in conjunction with the PIDControl class. The solved
ODE is of the form x''(t) = f(x(t)) + u(t).
Initialize with time parameters t_start, t_end, number of support
points N. Initial values are given to the solve method for
flexibility in calculating solutions for different initial
conditions. Right hand side can be adjusted, even though sine and
identity are the most reasonable choices.
"""
def __init__(self, t_start, t_end, N, f, L=0.1, G=9.81):
"""
Initialize linear or nonlinear pendulum.
:type t_start: float
:param t_start: starting time for ODE solving
:type t_end: float > t_start
:param t_end: final time for ODE solving
:type N: int > 0
:param N: number of numerical support points for ODE solving
:type f: function
:param f: right hand side for the second order pendulum ODE
:type L: float
:param L: pendulum length parameter in [m]
:type G: float > 0
:param G: gravitational constant in [m/s^2]
:output: object representing the second order pendulum ODE with
right hand side f
"""
self.t_start = t_start
self.t_end = t_end
self.N = N
self.f = f
self.L = L
self.G = G
# Calculate time step width:
self.h = (self.t_end - self.t_start)/self.N
# Define array with time support points:
self.t = [(self.t_start + i*self.h) for i in range(self.N + 1)]
def __repr__(self):
"""
Return string representation of inverted pendulum.
"""
return("Inverted Pendulum of Length {}".format(self.L))
def solve(self, phi0, phi0_dot, alpha, beta, mu, max_control, frequency,
deadband, set_point, precision):
"""
Method solving the ODE for given physical initial conditions,
i.e. initial angle and velocity, and with PID controller, that
has the given parameters.
:type phi0: float
:param phi0: initial value
:type phi0_dot: float
:param phi0_dot: initial angular velocity
:type alpha: float > 0
:param alpha: proportional control parameter
:type beta: float > 0
:param beta: derivative control parameter
:type mu: float > 0
:param mu: integral control parameter
:type max_control: float > 0
:param max_control: controller output bound
:type frequency: int >= 1
:param frequency: controller speed parameter
:type deadband: float
:param deadband: minimum difference between calculated control
outputs
:type set_point: float
:param set_point: desired value of controlled system
:type precision: int > 0
:param precision: measurement precision of controller input
:output: numerically calculates the attributes (float arrays)
phi, output_array, P_array, I_array and D_array
"""
self.phi0 = phi0
self.phi0_dot = phi0_dot
# Initialize solution array with given initial data:
self.phi = [self.phi0, self.phi0 + self.phi0_dot * self.h]
self.output_array = [0, 0]
self.P_array = [0, 0]
self.I_array = [0, 0]
self.D_array = [0, 0]
# Initialize PID controller:
self.alpha = alpha
self.beta = beta
self.mu = mu
self.max_control = max_control
self.frequency = frequency
self.deadband = deadband
self.set_point = set_point
self.precision = precision
# Create an instance of a PIDControl:
self.controller = PIDControl(self.alpha, self.beta, self.mu,
self.frequency, self.max_control,
self.set_point, self.deadband)
# Integrate the controlled ODE:
for n in range(1, self.N):
# Calculate the current control value:
u_n = self.controller.total_output(self.phi[n-1], self.phi[n],
self.t[n-1], self.t[n],
precision=self.precision)
# Save control values for control value plot:
self.output_array.append(u_n)
self.P_array.append(
self.controller.proportional_output(self.phi[n], self.t[n])
)
self.D_array.append(
self.controller.derivative_output(
self.phi[n-1], self.phi[n], self.t[n-1], self.t[n]
)
)
self.I_array.append(self.controller.integral)
# After this calculation, `tmp' contains the angle value phi[n+1]:
tmp = (
2.0*self.phi[n] + self.L*self.G*self.f(self.phi[n])*self.h**2
- self.phi[n-1] + u_n*self.h**2
)
self.phi.append(tmp)
def solve_from_angles(self, phi0, phi1, alpha, beta, mu, max_control,
frequency, deadband, set_point, precision):
"""
Method solving the ODE for given numerical initial conditions,
i.e. two initial angles. Works exactly like the solve() method.
:type phi0: float
:param phi0: first initial value
:type phi1: float
:param phi1: second initial value
:type alpha: float > 0
:param alpha: proportional control parameter
:type beta: float > 0
:param beta: derivative control parameter
:type mu: float > 0
:param mu: integral control parameter
:type max_control: float > 0
:param max_control: controller output bound
:type frequency: int >= 1
:param frequency: controller speed parameter
:type deadband: float
:param deadband: minimum difference between calculated control
outputs
:type set_point: float
:param set_point: desired value of controlled system
:type precision: int > 0
:param precision: measurement precision of controller input
:output: Numerically calculates the attributes (float arrays)
phi, output_array, P_array, I_array and D_array
>>> import numpy as np; from PID_control import *
>>> ALPHA = 4.4; BETA = 2.0; MU = 1.2; MAX_CONTROL = 2.6
>>> FREQUENCY = 30; DEADBAND = 0.01; SET_POINT = -0.0*np.pi
>>> PRECISION = 5; t_start = 0.0; t_end = 45.0; N = 9000; LENGTH = 0.1
>>> phi0 = 0.5 * np.pi; phi0_dot = 0.3 * np.pi
>>> pendulum = Pendulum(t_start, t_end, N, np.sin, L=LENGTH)
>>> pendulum
Inverted Pendulum of Length 0.1
>>> phi1 = phi0 + phi0_dot*pendulum.h
>>> pendulum.solve(
... phi0, phi0_dot, ALPHA, BETA, MU, MAX_CONTROL, FREQUENCY, DEADBAND,
... SET_POINT, PRECISION
... )
>>> x = pendulum.phi[10]
>>> pendulum.solve_from_angles(
... phi0, phi1, ALPHA, BETA, MU, MAX_CONTROL, FREQUENCY, DEADBAND,
... SET_POINT, PRECISION
... )
>>> y = pendulum.phi[10]
>>> print(np.abs(x - y) < 5e-5)
True
"""
self.phi0 = phi0
self.phi1 = phi1
# Initialize solution array with given initial angles:
self.phi = [self.phi0, self.phi1]
self.output_array = [0, 0]
self.P_array = [0, 0]
self.I_array = [0, 0]
self.D_array = [0, 0]
# Initialize PID controller:
self.alpha = alpha
self.beta = beta
self.mu = mu
self.max_control = max_control
self.frequency = frequency
self.deadband = deadband
self.set_point = set_point
self.precision = precision
# Create an instance of a PIDControl:
self.controller = PIDControl(self.alpha, self.beta, self.mu,
self.frequency, self.max_control,
self.set_point, self.deadband)
# Integrate the controlled ODE:
for n in range(1, self.N):
# Calculate the current control value:
u_n = self.controller.total_output(self.phi[n-1], self.phi[n],
self.t[n-1], self.t[n],
precision=self.precision)
# Save control values for control value plot:
self.output_array.append(u_n)
self.P_array.append(
self.controller.proportional_output(self.phi[n], self.t[n])
)
self.D_array.append(
self.controller.derivative_output(
self.phi[n-1], self.phi[n], self.t[n-1], self.t[n]
)
)
self.I_array.append(self.controller.integral)
# After the following calculation, tmp contains the entry
# phi[n + 1]:
tmp = (2.0*self.phi[n] + self.f(self.phi[n])*self.h**2
- self.phi[n-1] + u_n*self.h**2)
self.phi.append(tmp)
def get_func_values(self):
"""
A convenience method that returns the calculated function values
or an empty list if `solve` was never called on this pendulum.
:output: array containing angle solution values (floats)
"""
if hasattr(self, "phi"):
return self.phi
else:
return []
def get_support_values(self):
"""
A convenience method that returns the support values (== time
points)or an empty list if `solve` was never called on this
pendulum.
:output: array containing support values (floats)
"""
if hasattr(self, "t"):
return self.t
else:
return []
def plot(self, file_name, parameter=False):
"""
Method to plot solutions generated with Pendulum class. One needs to
call the solve() method, before plot() can be called. PID Parameters
can be written in the filename. This might be useful for numerical
experiments with several distinct sets of parameters.
:type file_name: string
:param file_name: name for the .png file, in which the solution
gets stored
:type parameter: bool
:param parameter: if true, controller parameters are written in
the filename
:todo: fix naming scheme (Linear vs Nonlinear; testing for
(lambda x: x) == self.f is not implemented very nicely).
"""
# Plot time dependencies of system, i.e. angle phi, and control
# output:
plt.figure()
plt.plot(self.t, self.phi, "g-", label="Pendulum Angle")
# Try to fit the correct name to the kind of pendulum
# integrated. This fails to make sense, if self.f is anything
# else than np.sin or (lambda x: x)!
if self.f == np.sin:
name = " Nonlinear "
elif (self.f(np.e) == np.e) and (self.f(np.sqrt(2)) == np.sqrt(2)):
name = " Linear "
else:
name = " Disturbed "
plt.plot(self.t, self.output_array, "r-", label="Controller Output")
plt.title(
"PID controlled" + name + "Inverted Pendulum with Parameters\n"
"alpha = {}, beta = {}, mu = {}, max_output = {}, frequency = {}, "
"deadband = {}, precision = {}".format(
self.alpha, self.beta, self.mu,
self.max_control, self.frequency,
self.deadband, self.precision
)
)
plt.xlabel("$t$ (s)", fontsize=15)
plt.ylabel("$\phi$ ($2\pi$)", fontsize=15) # noqa: LaTeX escape seq
plt.tick_params(labelsize=15)
plt.xlim(self.t_start, self.t_end)
plt.ylim(-self.max_control - 0.05, self.max_control + 0.05)
plt.legend(loc="upper right", shadow=True)
plt.grid(True)
# Catch exception, if directory pics/ does not exist:
try:
if parameter:
plt.savefig("pics/" + file_name + "_{}_{}_{}_1.png".format(
self.alpha, self.beta, self.mu
))
else:
plt.savefig("pics/" + file_name + "_1.png")
except FileNotFoundError:
print("Warning: Please create directory `pics' to save plots to.")
exit(1)
# Plot P, I, D and total control outputs together in one diagram:
plt.figure()
plt.plot(self.t, self.output_array, "b--",
label="Total Control Output")
plt.plot(self.t, self.P_array, "y--",
label="Proportional Control Output")
plt.plot(self.t, self.I_array, "r--", label="Integral Control Output")
plt.plot(self.t, self.D_array, "g--",
label="Derivative Control Output")
plt.title("Control Values")
plt.xlabel("$t$", fontsize=15)
plt.ylabel("Controls", fontsize=15)
plt.xlim(self.t_start, self.t_end)
plt.ylim(-self.max_control - 0.05, self.max_control + 0.05)
plt.legend(loc="upper right", shadow=True)
plt.grid(True)
if parameter:
plt.savefig("pics/" + file_name
+ "_{}_{}_{}_2.png".format(
self.alpha, self.beta, self.mu)
)
else:
plt.savefig("pics/" + file_name + "_2.png")
plt.show()
def animate(self, anim_name):
"""
Method to animate solutions generated with Pendulum class. One
needs to call the solve() method, before plot() makes sense.
:type anim_name: string
:param anim_name: name for the mp4 file, in which the animation
gets stored
"""
# Set up formatting for the movie files:
Writer = animation.writers['ffmpeg']
writer = Writer(fps=35, bitrate=1800)
fig = plt.figure()
ax = plt.axes(xlim=(self.t_start, self.t_end), ylim=(
-self.max_control - 0.01, self.max_control + 0.01
))
plt.grid(True)
line, = ax.plot([], [], lw=2)
plt.xlabel('$t$')
plt.ylabel('$\phi$') # noqa: LaTeX escape seq
# Initialize the animation:
def init():
line.set_data([], [])
return line,
# Define the function, that is animated, from pendulum solution data:
def animate(i):
x = self.t[:i]
y = self.phi[:i]
line.set_data(x, y)
return line,
anim = animation.FuncAnimation(
fig, animate, init_func=init, frames=self.N, interval=2, blit=True
)
# Saves with the formatting set up earlier:
try:
anim.save("pics/" + anim_name + ".mp4", writer=writer)
except FileNotFoundError:
print("Warning: Please create directory `pics' to save animation.")
exit(1)
################################
# Animated Controlled Pendulum #
################################
class AnimatedPendulum():
"""
Class especially tailored to creating, solving and finally animating
a controlled inverted pendulum. While the Pendulum class method
animate() can be called after solving the pendulum ODE with solve(),
the AnimatedPendulum class wraps these steps. Simply create an
instance and call the animate() method.
"""
def __init__(self, phi0, phi0_dot, alpha, beta, mu, max_control, frequency,
deadband, set_point, precision, t_start, t_end, N, L, f):
"""
:type phi0: float
:param phi0: initial angle value
:type phi0_dot: float
:param phi0_dot: initial angle velocity value
:type alpha: float > 0
:param alpha: proportional control parameter
:type beta: float > 0
:param beta: derivative control parameter
:type mu: float > 0
:param mu: integral control parameter
:type max_control: float > 0
:param max_control: controller output bound
:type frequency: int >= 1
:param frequency: controller speed parameter
:type deadband: float
:param deadband: minimum difference between calculated control
outputs
:type set_point: float
:param set_point: desired value of controlled system
:type precision: int > 0
:param precision: measurement precision of controller input
:type t_start: float
:param t_start: starting time for pendulum dynamics
:type t_end: float > t_start
:param t_end: ending time for pendulum dynamics
:type N: int > 0
:param N: number of support points
:type L: float > 0
:param L: pendulum length
:type f: function
:param f: right hand side for pendulum ODE
:output: Creates an instance of a pendulum, waiting to be
animated
"""
self.phi0 = phi0
self.phi0_dot = phi0_dot
self.alpha = alpha
self.beta = beta
self.mu = mu
self.max_control = max_control
self.frequency = frequency
self.deadband = deadband
self.set_point = set_point
self.precision = precision
self.t_start = t_start
self.t_end = t_end
self.N = N
self.L = L
self.f = f
def animate(self, anim_name):
"""
Animates an instance of AnimatedPendulum.
:type anim_name: string
:param anim_name: name for the mp4 file, in which the animation
gets stored
"""
# Set up formatting for the movie files:
Writer = animation.writers['ffmpeg']
writer = Writer(fps=35, bitrate=1800)
fig = plt.figure()
ax = plt.axes(xlim=(self.t_start, self.t_end), ylim=(
-self.max_control - 0.01, self.max_control + 0.01
))
plt.grid(True)
line, = ax.plot([], [], lw=2)
plt.xlabel('$t$')
plt.ylabel('$\phi$') # noqa: LaTeX escape seq
# Initialize the animation:
def init():
line.set_data([], [])
return line,
# Initialize pendulum, this differentiations AnimatedPendulum
# method animate() from Pendulum method animate():
pendulum = Pendulum(self.t_start, self.t_end, self.N, self.f, self.L)
pendulum.solve(
self.phi0, self.phi0_dot, self.alpha, self.beta, self.mu,
self.max_control, self.frequency, self.deadband, self.set_point,
self.precision
)
# Define the function, that is animated, from pendulum data:
def animate(i):
x = pendulum.get_support_values()[:i]
y = pendulum.get_func_values()[:i]
line.set_data(x, y)
return line,
anim = animation.FuncAnimation(
fig, animate, init_func=init, frames=self.N, interval=2, blit=True
)
# Saves with the formatting set up earlier:
try:
anim.save("pics/" + anim_name + ".mp4", writer=writer)
except FileNotFoundError:
print("Warning: Please create directory `pics' to save animation.")
exit(1)
###############################################################################
# :todo: Implement and investigate (random) noise; use PERTURBATION parameter
# or maybe even a stochastic function of time
# :todo: Implement optimality criteria (at least speed of first achieving the
# set point and overswing width around the set point).
# :todo: Implement functionality for variable set point.
# :todo: Implement integral anti-windup (deactivate integrator, if difference
# between system value and set point is too small)?
# :todo: Implement (in ODE) friction.
# :todo: Raise exceptions, when incorrect parameters are supplied!
# :todo: Improve doctest coverage!
###############################################################################