When we command a motor to spin for two seconds, we assume that the resulting movement is predictable. Friction, battery voltage and load can change the result.

Open-loop control

The program sends a command without measuring the result. It is simple, but it cannot automatically correct an unexpected disturbance.

Closed-loop control

The robot measures its position or speed and compares the measurement with a target. The difference is called the error. The controller adjusts its output to reduce this error.

A proportional controller

A basic rule is u = Kp * error, where Kp is a chosen gain. A larger gain can produce stronger correction, but too much gain can cause oscillation or instability.

Experiment

Plot target speed, measured speed and error over time. Change only one variable in each experiment. This is more informative than selecting gains by intuition.