Open Loop vs Closed Loop

You tell your robot to drive forward 1 meter. It starts moving, but when you measure, it only went 0.87 meters. You tell it to turn 90 degrees. It turns 103 degrees instead. What went wrong?
The answer lies in whether your control system uses feedback or not. This is the difference between open-loop and closed-loop control — and it's one of the most fundamental concepts in robotics.
Open-Loop Control: Fire and Forget
In an open-loop control system, you send a command and hope for the best. There's no sensor checking whether the robot actually did what you asked.
Here's a simple example — you want to heat a room to 22°C:
class OpenLoopHeater:
def __init__(self):
self.heater = Heater()
def heat_to_22_celsius(self):
# Turn heater on at 60% power for 5 minutes
self.heater.set_power(0.6)
time.sleep(5 * 60)
self.heater.set_power(0.0)
# Done! (we hope)This might work on a perfect day when the outside temperature is 15°C and there's no wind. But what if:
- It's actually 5°C outside? The room won't reach 22°C in 5 minutes.
- Someone opens a window? The heat escapes.
- The heater is less efficient than expected? It takes longer.

Open-loop control has no way to know if the goal was achieved. It just executes the plan blindly.
When Open-Loop Works
Open-loop isn't always bad. It's simple, fast, and works well when:
- The system is predictable (a stepper motor moving a 3D printer head)
- The disturbances are minimal (a door lock — either locked or not)
- The consequences of error are acceptable (a washing machine timer)
But for robots moving in the real world? Almost never good enough.
Closed-Loop Control: Measure and Adjust
In a closed-loop control system, you continuously measure the output and adjust the input based on the error — the difference between what you want and what you have.
Same heating example, but with a thermometer:
class ClosedLoopHeater:
def __init__(self):
self.heater = Heater()
self.thermometer = Thermometer()
def heat_to_22_celsius(self):
target_temp = 22.0
while True:
current_temp = self.thermometer.read()
error = target_temp - current_temp
if abs(error) < 0.5: # Close enough
self.heater.set_power(0.0)
break
# Simple proportional control
power = min(1.0, max(0.0, error / 10.0))
self.heater.set_power(power)
time.sleep(1) # Check every secondNow the system adapts to disturbances. Window opens? The thermometer sees the temperature drop and the heater powers up. Outside temperature changes? The control loop adjusts automatically.
This is feedback — using the sensor output to modify the control input.

The term "closed loop" comes from the circular flow of information: sensor → controller → actuator → sensor. The loop is "closed" because the output feeds back into the input.
Robotics Example: Driving Straight
Let's make this concrete with a robot driving forward.
Open-Loop Approach:
# Command: Drive 1 meter forward
left_motor.set_speed(0.5) # 0.5 m/s
right_motor.set_speed(0.5) # 0.5 m/s
time.sleep(2.0) # 2 seconds = 1 meter
left_motor.set_speed(0.0)
right_motor.set_speed(0.0)
# Problems:
# - Left motor slightly weaker → robot veers right
# - Friction varies on carpet vs hardwood → speed changes
# - Battery voltage drops → motors slow down
# - Wheel slips on a bump → actual distance < 1 meterClosed-Loop Approach:
# Command: Drive 1 meter forward
target_distance = 1.0 # meters
start_position = encoders.read_distance()
while True:
current_position = encoders.read_distance()
traveled = current_position - start_position
error = target_distance - traveled
if error < 0.01: # Within 1cm
break
# Adjust speed based on remaining distance
speed = min(0.5, error * 0.3)
left_motor.set_speed(speed)
right_motor.set_speed(speed)
time.sleep(0.02) # 50 Hz control loop
left_motor.set_speed(0.0)
right_motor.set_speed(0.0)
# This compensates for:
# - Motor differences (encoders detect veering, controller adjusts)
# - Surface friction (slower progress → maintains speed longer)
# - Battery voltage (encoders measure actual motion, not commanded motion)

The closed-loop version measures reality and adjusts until the goal is met.
The Core Components
Every closed-loop control system has three parts:
- Sensor — Measures the current state (encoders, thermometer, IMU, etc.)
- Controller — Compares desired state to actual state, computes a correction
- Actuator — Executes the correction (motors, heater, servo, etc.)
The information flows in a loop:
This is the sense-think-act loop we've seen throughout this course — but now with the explicit feedback connection.
What's Next?
Now that you understand the power of feedback, the next question is: how do you calculate the correction? How much more power should the heater get if the room is 2°C too cold? How fast should the robot turn to correct a 5-degree heading error?
The answer is PID control — the most common control algorithm in robotics. We'll break it down step by step in the next lesson.