Atlas Robotics
Robot ControlBasic

Closed-loop control: the principle behind PID, Nav2 and AMCL

Atlasbot · 17/8/2026 · 11 min read

Closed-loop control: the principle behind PID, Nav2 and AMCL
Compare open-loop and closed-loop block diagrams

The previous articles in this category — PID, Speed ​​control — are all specific applications of a single principle: closed-loop control. This article takes a step back, looking at that principle in its most general form, to see it repeated at every level of a robotic system.

Key concepts

Open-loop (open loop) is control without feedback — give a command once, trust the system to execute correctly, never check the actual result again:

command → system → result (no re-measurement, no comparison with target)

For example, set the microwave timer for 2 minutes without a temperature sensor — the oven runs for exactly 2 minutes regardless of whether the food is hot enough or not. Simple, cheap, but not self-correcting when actual conditions are different from assumptions.

How it works

Closed-loop (closed loop) adds a feedback loop: measure the actual result, compare it with the target, use that deviation to adjust the next command:

command → system → actual result
   ↑                    │
   └──── compare with target, generate new command ────┘

In short: The core difference is not in algorithmic complexity — a simple PID is still closed-loop, a complex system that does not measure results is still open-loop. The only question to answer: does the system self-check and correct errors based on actual results?

The same principle appears at many different levels:

FloorWhat to measure (feedback)Compare with what?How to correct mistakes?
Control motor speedEncoderDesired speedPID PWM adjustment
path follows (Nav2 controller)Physical location (odometry/AMCL)Path made a planAdjust v, ω
localization (AMCL)Actual LiDAR scanningScan predictions according to the mapAdjust position estimates
Charge the battery automaticallyMeasured battery voltageFull battery thresholdAdjust charging current

Technical details

Formulas

With a simple proportional feedback loop, steady-state error decreases with the gain of the loop — a simplified formula that illustrates why increasing gain reduces error but not "higher is better":

Sai_so_on_dinh = Sai_so_open_loop / (1 + Gain_vong_lap)

For example: assumed open-loop error is 10 units, loop gain = 9
Sai_so_on_dinh = 10 / (1 + 9) = 1 unit (reduced 10 times)

The higher the gain, the lower the error — BUT too high a gain combines with system latency
large is a classic formula that causes unstable fluctuations (warned below).

Parameters

Sensor latency is part of the overall loop latency, which varies greatly depending on the sensor type — this is why different closed-loop layers must run at different frequencies accordingly:

Feedback sensorTypical latency
Encoder (read directly via GPIO/timer)Under 1ms
1 full LiDAR scan~50-100ms (depending on scanning frequency)
AI inference on camera images~30-100ms depending on model/hardware

Practical applications

A complete ROS2 robot system is essentially a series of nested and interdependent closed-loops — when one layer "breaks" (eg: broken encoder causes the speed PID loop to lose feedback, automatically falling back to open-loop-like behavior), all closed-loop layers built above it (path tracking, AMCL localization) are chain-affected even though they themselves still operate logically — because of the input they receive (odometry data from the lower ring) was no longer reliable. A good robot system design needs to take into account the ability to detect when a layer of feedback is lost/degraded (e.g., monitor long-term abnormal PID errors) and have a corresponding safe response (decelerate, stop, report an error), instead of letting the error silently propagate through the entire chain of nested loops.

Practical example

# Compare open-loop vs closed-loop when there is disturbance midway
target = 10.0

# Open-loop: follow the original command, do not measure again
open_loop_output = target  # always = 10, no matter what noise occurs

# Closed-loop: re-measure and correct errors at each step
actual = 0.0
gain = 0.5
disturbance = -3.0  # Noise pulls down the actual value in the middle step

for step in range(6):
    if step == 3:
        actual += disturbance  # interference occurs
    error = target - actual
    actual += gain * error

    print(f"Step {step}: open_loop={open_loop_output}, closed_loop_actual={actual:.2f}")
Output:
Step 0: open_loop=10.0, closed_loop_actual=5.00
Step 1: open_loop=10.0, closed_loop_actual=7.50
Step 2: open_loop=10.0, closed_loop_actual=8.75
Step 3: open_loop=10.0, closed_loop_actual=2.94
Step 4: open_loop=10.0, closed_loop_actual=6.47
Step 5: open_loop=10.0, closed_loop_actual=8.23

open_loop always reports "10" unchanged (just an instruction number, not reflecting reality) — while closed_loop_actual shows the true value, drops when noise occurs in step 3 and then automatically gradually recovers in the following steps, true to the "measure → compare → correct" nature of closed-loop.

Common mistakes

  • Confusing a "complex" system with a "closed-loop" system — as mentioned in the Principle of Operation section, algorithm complexity does not determine open-loop or closed-loop — only whether to measure the actual results or not does.
  • Gain is too high combined with large delay causing oscillations — according to the formula stated in the Formula section, high gain reduces errors but if the system delay is large, the "error correction" loop is based on old information, easily overcorrecting in both directions causing oscillations instead of convergence.
  • Ignore sensor delay when tuning gain — tune gain is only based on ideal simulation (no delay) and then applied directly to the real system (with actual sensor delay) often causing unexpected instability.
  • Add closed-loop to everything "just to be sure" — not all systems need feedback; adding sensors and feedback loops for low-volatile or unimportant quantities causes unnecessary hardware costs/complexity — consider whether open-loop is sufficient before defaulting to closed-loop.

Conclusion

Closed-loop control is the unifying principle behind all the control mechanisms learned in this section — from motor speed PID, acceleration limiter, trajectory tracking, to AMCL localization — all of which are "measure → compare → correct" at different stages and frequencies. Understanding the trade-offs between gain, delay, and stability is key to designing reliable robot control systems. This is also the last lesson of the Robot Control section - the closed-loop lesson just compiled applies directly to the next section: Localization, where the robot uses this principle to continuously correct its own estimated position.

Get new articles and lessons by email

When a new technical article or course module is published, Atlas Robotics sends you a short email. No spam.

Unsubscribe any time with the link in each email. See our Privacy policy.

Closed-loop control: the principle behind PID, Nav2 and AMCL — Atlas Robotics