Skip to content

Error in Control Systems

In a control system, error is the difference between the desired state and the actual state of a system. The goal of any control algorithm is to minimize this error over time.

\[e = \text{desired} - \text{actual}\]

This single idea — measuring error and correcting for it — is the foundation of every control algorithm on this site: PID, Pure Pursuit, Stanley, and more. The type of error you measure depends entirely on what you're trying to control.

What is "error" in the context of a control system?

Types of Error

1. Position Error

The simplest form of error: how far is the robot from where it needs to be?

\[e_{\text{pos}} = \text{goal position} - \text{current position}\]

Example: A robot needs to drive 2 meters forward but has only moved 1.3 meters. The position error is 0.7 meters. A PID controller uses this error to decide how much power to apply to the motors.


2. Cross-Track Error (CTE)

When a robot is following a path (rather than a single point), position error alone isn't enough. The robot could be the right distance along the path but drifting sideways off of it.

Cross-track error is the perpendicular distance from the robot's current position to the nearest point on the reference path.

\[e_{\text{cte}} = \text{perpendicular distance from robot to path}\]
Cross-Track Error Diagram
The robot (dot) has drifted off the reference path. CTE is the shortest distance back to the path.
  • CTE = 0 → the robot is perfectly on the path.
  • CTE > 0 → the robot has drifted to one side and needs to steer back.

Cross-track error is the primary error signal used by Pure Pursuit and Stanley controllers.

What does cross-track error (CTE) measure?

3. Heading Error

Even if a robot is on the path, it might be pointing in the wrong direction — which means it will drift off again shortly. Heading error is the difference between the robot's current orientation and the direction the path is heading at that point.

\[e_{\theta} = \theta_{\text{path}} - \theta_{\text{robot}}\]

Example: The path curves left, but the robot is still pointed slightly right. The heading error is the angle between the robot's nose and the tangent of the path.

  • Stanley corrects for both CTE and heading error simultaneously, which is why it handles curves more precisely than Pure Pursuit.
  • Pure Pursuit implicitly accounts for heading error by aiming at a lookahead point, but doesn't compute it directly.

4. Velocity Error

When controlling speed, the error is the gap between the target speed and the current speed.

\[e_v = v_{\text{desired}} - v_{\text{actual}}\]

Example: A cruise control system wants to maintain 30 km/h. If the car is doing 27 km/h on an uphill slope, the velocity error is 3 km/h, and the controller increases the throttle to compensate.


5. Steering Angle Error

When controlling a steering mechanism, the error is the difference between the desired and current steering angle.

\[e_{\delta} = \delta_{\text{desired}} - \delta_{\text{current}}\]

Example: A robot needs to turn its wheels to 15° to follow a curve, but they're currently at 8°. The steering error is 7°, and the controller actuates the steering to close that gap.


Which Error Does Each Algorithm Use?

Algorithm Primary Error Signal
PID Position, velocity, or steering angle error — whatever you're controlling
Pure Pursuit Cross-track error (implicitly, via lookahead geometry)
Stanley Cross-track error + heading error
Differential Drive Heading error + position error

Understanding which type of error an algorithm minimizes tells you a lot about when to use it and why it behaves the way it does.

Which controller corrects for both cross-track error and heading error simultaneously?

Multiple Controllers for Multiple Errors

A single robot often has multiple sources of error to manage at once. For example, a car following a curved road might need:

  • One controller managing velocity (keeping speed constant)
  • Another managing steering (keeping the car on the path using CTE and heading error)

Each controller runs independently, feeding its own error signal into its own algorithm. This modular approach is one of the reasons PID and path-following controllers are so widely combined in real robotic systems.