Thomas Piacentini
← Workshop

12 / 15 · 90–120 min

Track a target.

How can feedback correct a movement?

Choose a laboratory
Check my intuition

01 · Predict

Before changing the settings.

With Kp = 3 alone and a position error of 2 m, what unsaturated proportional command results?

A hint

u = Kp × error

02 · Experiment and compare

Put the model to the test.

Start with Ki and Kd at zero. Add derivative action to damp motion, then integral action to compensate for a constant disturbance. Observe the limited command and error after 5 s.

000.92.51.852.77.53.710Position (m)t (s)
Dashed: target. Solid: position. The constant disturbance begins at 5 s.

Unit mass, command limited to ±8 m/s². The target changes at 1 s; a constant disturbance appears at 5 s. The derivative term uses measured velocity, with integral anti-windup.

Final error
-0.06 m
Current command
-0.51 m/s²
RMS error
0.78 m
Compare A and B →

Read values as a table
t (s)Target (m)x (m)v (m/s)u (m/s²)Error (m)
0.050.000.000.000.000.00
0.100.000.000.000.000.00
0.150.000.000.000.000.00
0.200.000.000.000.000.00
0.250.000.000.000.000.00
0.300.000.000.000.000.00
0.350.000.000.000.000.00
0.400.000.000.000.000.00
0.450.000.000.000.000.00
0.500.000.000.000.000.00
0.550.000.000.000.000.00
0.600.000.000.000.000.00
0.650.000.000.000.000.00
0.700.000.000.000.000.00
0.750.000.000.000.000.00
0.800.000.000.000.000.00
0.850.000.000.000.000.00
0.900.000.000.000.000.00
0.950.000.000.000.000.00
1.003.000.020.408.002.98
1.053.000.060.788.002.94
1.103.000.121.127.402.88
1.153.000.191.416.702.81
1.203.000.271.666.052.73
1.253.000.361.865.442.64
1.303.000.462.034.882.54
1.353.000.572.174.372.43
1.403.000.692.283.892.31
1.453.000.802.363.452.20
1.503.000.932.423.042.07
1.553.001.052.452.671.95
1.603.001.172.472.321.83
1.653.001.302.472.011.70
1.703.001.422.461.721.58
1.753.001.542.441.451.46
1.803.001.662.401.211.34
1.853.001.782.350.991.22
1.903.001.892.300.801.11
1.953.002.002.240.611.00
2.003.002.112.170.450.89
2.053.002.222.100.300.78
2.103.002.322.020.170.68
2.153.002.421.940.050.58
2.203.002.511.86-0.050.49
2.253.002.601.78-0.150.40
2.303.002.681.70-0.230.32
2.353.002.761.62-0.300.24
2.403.002.841.53-0.370.16
2.453.002.911.45-0.420.09
2.503.002.981.37-0.470.02
2.553.003.051.29-0.51-0.05
2.603.003.111.21-0.55-0.11
2.653.003.161.13-0.58-0.16
2.703.003.221.06-0.60-0.22
2.753.003.270.98-0.62-0.27
2.803.003.310.91-0.63-0.31
2.853.003.350.84-0.64-0.35
2.903.003.390.78-0.65-0.39
2.953.003.430.71-0.65-0.43
3.003.003.460.65-0.66-0.46
3.053.003.490.59-0.65-0.49
3.103.003.520.54-0.65-0.52
3.153.003.540.48-0.64-0.54
3.203.003.560.43-0.64-0.56
3.253.003.580.38-0.63-0.58
3.303.003.600.34-0.62-0.60
3.353.003.610.29-0.60-0.61
3.403.003.630.25-0.59-0.63
3.453.003.640.21-0.58-0.64
3.503.003.650.18-0.56-0.65
3.553.003.650.14-0.55-0.65
3.603.003.660.11-0.53-0.66
3.653.003.660.08-0.52-0.66
3.703.003.660.05-0.50-0.66
3.753.003.670.02-0.49-0.67
3.803.003.673.35E-4-0.47-0.67
3.853.003.67-0.02-0.46-0.67
3.903.003.66-0.04-0.44-0.66
3.953.003.66-0.06-0.42-0.66
4.003.003.66-0.08-0.41-0.66
4.053.003.65-0.10-0.39-0.65
4.103.003.65-0.11-0.38-0.65
4.153.003.64-0.13-0.36-0.64
4.203.003.63-0.14-0.35-0.63
4.253.003.62-0.15-0.34-0.62
4.303.003.62-0.16-0.32-0.62
4.353.003.61-0.17-0.31-0.61
4.403.003.60-0.18-0.30-0.60
4.453.003.59-0.18-0.28-0.59
4.503.003.58-0.19-0.27-0.58
4.553.003.57-0.20-0.26-0.57
4.603.003.56-0.20-0.25-0.56
4.653.003.55-0.20-0.24-0.55
4.703.003.54-0.21-0.23-0.54
4.753.003.53-0.21-0.22-0.53
4.803.003.52-0.21-0.21-0.52
4.853.003.51-0.21-0.20-0.51
4.903.003.50-0.21-0.19-0.50
4.953.003.49-0.21-0.18-0.49
5.003.003.48-0.19-0.17-0.48
5.053.003.47-0.17-0.22-0.47
5.103.003.46-0.15-0.26-0.46
5.153.003.46-0.13-0.30-0.46
5.203.003.45-0.12-0.33-0.45
5.253.003.44-0.11-0.36-0.44
5.303.003.44-0.10-0.39-0.44
5.353.003.43-0.09-0.42-0.43
5.403.003.43-0.08-0.44-0.43
5.453.003.43-0.08-0.47-0.43
5.503.003.42-0.07-0.48-0.42
5.553.003.42-0.07-0.50-0.42
5.603.003.42-0.07-0.52-0.42
5.653.003.41-0.07-0.53-0.41
5.703.003.41-0.07-0.55-0.41
5.753.003.41-0.07-0.56-0.41
5.803.003.40-0.07-0.57-0.40
5.853.003.40-0.07-0.58-0.40
5.903.003.40-0.07-0.58-0.40
5.953.003.39-0.07-0.59-0.39
6.003.003.39-0.07-0.59-0.39
6.053.003.38-0.08-0.60-0.38
6.103.003.38-0.08-0.60-0.38
6.153.003.38-0.08-0.61-0.38
6.203.003.37-0.08-0.61-0.37
6.253.003.37-0.08-0.61-0.37
6.303.003.36-0.09-0.61-0.36
6.353.003.36-0.09-0.61-0.36
6.403.003.35-0.09-0.61-0.35
6.453.003.35-0.09-0.61-0.35
6.503.003.35-0.10-0.61-0.35
6.553.003.34-0.10-0.61-0.34
6.603.003.34-0.10-0.61-0.34
6.653.003.33-0.10-0.61-0.33
6.703.003.33-0.10-0.61-0.33
6.753.003.32-0.10-0.61-0.32
6.803.003.31-0.10-0.60-0.31
6.853.003.31-0.10-0.60-0.31
6.903.003.30-0.11-0.60-0.30
6.953.003.30-0.11-0.60-0.30
7.003.003.29-0.11-0.60-0.29
7.053.003.29-0.11-0.59-0.29
7.103.003.28-0.11-0.59-0.28
7.153.003.28-0.11-0.59-0.28
7.203.003.27-0.11-0.59-0.27
7.253.003.27-0.11-0.58-0.27
7.303.003.26-0.11-0.58-0.26
7.353.003.26-0.11-0.58-0.26
7.403.003.25-0.11-0.58-0.25
7.453.003.25-0.11-0.57-0.25
7.503.003.24-0.10-0.57-0.24
7.553.003.24-0.10-0.57-0.24
7.603.003.23-0.10-0.57-0.23
7.653.003.22-0.10-0.56-0.22
7.703.003.22-0.10-0.56-0.22
7.753.003.21-0.10-0.56-0.21
7.803.003.21-0.10-0.56-0.21
7.853.003.20-0.10-0.56-0.20
7.903.003.20-0.10-0.55-0.20
7.953.003.20-0.10-0.55-0.20
8.003.003.19-0.09-0.55-0.19
8.053.003.19-0.09-0.55-0.19
8.103.003.18-0.09-0.55-0.18
8.153.003.18-0.09-0.54-0.18
8.203.003.17-0.09-0.54-0.17
8.253.003.17-0.09-0.54-0.17
8.303.003.16-0.09-0.54-0.16
8.353.003.16-0.08-0.54-0.16
8.403.003.16-0.08-0.54-0.16
8.453.003.15-0.08-0.53-0.15
8.503.003.15-0.08-0.53-0.15
8.553.003.14-0.08-0.53-0.14
8.603.003.14-0.08-0.53-0.14
8.653.003.14-0.07-0.53-0.14
8.703.003.13-0.07-0.53-0.13
8.753.003.13-0.07-0.53-0.13
8.803.003.13-0.07-0.53-0.13
8.853.003.12-0.07-0.52-0.12
8.903.003.12-0.07-0.52-0.12
8.953.003.12-0.07-0.52-0.12
9.003.003.11-0.06-0.52-0.11
9.053.003.11-0.06-0.52-0.11
9.103.003.11-0.06-0.52-0.11
9.153.003.10-0.06-0.52-0.10
9.203.003.10-0.06-0.52-0.10
9.253.003.10-0.06-0.52-0.10
9.303.003.09-0.05-0.52-0.09
9.353.003.09-0.05-0.52-0.09
9.403.003.09-0.05-0.52-0.09
9.453.003.09-0.05-0.52-0.09
9.503.003.08-0.05-0.51-0.08
9.553.003.08-0.05-0.51-0.08
9.603.003.08-0.05-0.51-0.08
9.653.003.08-0.05-0.51-0.08
9.703.003.08-0.04-0.51-0.08
9.753.003.07-0.04-0.51-0.07
9.803.003.07-0.04-0.51-0.07
9.853.003.07-0.04-0.51-0.07
9.903.003.07-0.04-0.51-0.07
9.953.003.07-0.04-0.51-0.07
10.003.003.06-0.04-0.51-0.06
Understand the calculations

03 · Connect the diagram to calculations

The numbers behind motion.

The robot is a unit mass moving along a line with drag. Semi-implicit integration at a fixed 0.05 s step simulates velocity and position. The measurement derivative provides −Kd v and avoids a target-change kick. The command is limited to ±8; the integral does not grow in the direction of saturation. These gains belong to this simulation and are not real-robot tuning values.

e = target − x
I ← I + e Δt
u = clip(Kp e + Ki I − Kd v, −8, 8)
v ← v + Δt(u + disturbance − drag v)
x ← x + Δt v
A few lines to reconstruct
error = target - position
command = kp * error + ki * integral - kd * velocity
velocity += dt * (command + disturbance - drag * velocity)
position += dt * velocity

The notebook provides one function per laboratory, hand-calculated examples and tests. Exercises isolate components; these pages run the complete simulations.

Keep an observation

04 · Record

What changed?

Compare two settings. Record the effect, your explanation and a case where the model might fail. Saving keeps the current settings and seed, not a certification of competence.

Open my notebook →

atomsh / lab