How Does an Autonomous Robot Work? Sense, Think, Act
The sense, think, act loop behind robots that decide for themselves
A robot vacuum slips around a chair leg, a warehouse robot finds the shortest route to a shelf: none of them waits for a human to press a button for every move. In this lesson you will discover the loop every autonomous robot runs and experiment with noisy sensors, path planning and motor control.

Learning objectives
- Explain what makes a robot autonomous
- Describe the sense, think, act loop
- Name common sensors and explain why readings are noisy and filtered
- Explain localization, mapping and path planning, and compare A* with BFS
- Explain proportional control and the effect of its gain
- Recognize the limits of robots and the importance of safety
A robot vacuum slips around a chair leg, a warehouse robot finds the shortest route to a shelf, a rover drives on another planet with a long delay in communication. None of them waits for someone to press a button for every move. How do they do it? In about 25 minutes you will discover the loop every autonomous robot runs, and you will experiment with noisy sensors, path planning and motor control in three interactive demos. A self-graded quiz closes the lesson.
- Time: 25 minutes
- Level: beginner
- Prerequisites: none
- You need: a web browser
1. What makes a robot autonomous?
A robot is a machine that can sense its environment and act on it. It is autonomous when it chooses its own actions to reach a goal, using what its sensors tell it, without a human controlling every move.
| Type | Who decides? | Example |
|---|---|---|
| Remote-controlled | A human, at every moment | A toy car with a handheld controller |
| Automatic | A fixed program, with no real awareness of the surroundings | A machine repeating the same arm movement on an assembly line |
| Autonomous | The robot, based on sensor data and its goal | A robot vacuum cleaner that avoids furniture and returns to its dock |
Autonomy is not all or nothing. Many robots are partly autonomous: they handle routine decisions alone and ask a human for help in unusual situations.
2. The sense, think, act loop
Almost every autonomous robot, from a classroom robot to a self-driving car, repeats the same cycle many times per second:
The loop never stops: after each action the world has changed, so the robot senses again and corrects itself. This repeated feedback is what lets a robot cope with surprises, such as a person walking into its path.
3. Sense: sensors and noise
A sensor turns a physical quantity into a number a computer can use. Different tasks need different sensors:
| Sensor | What it measures | Typical use |
|---|---|---|
| Ultrasonic | Distance, by timing a sound echo | Detecting walls and obstacles at short range |
| Lidar | Distance, by timing laser light | Building precise maps around the robot |
| Camera | Images | Recognizing objects, lanes or people |
| IMU (inertial unit) | Acceleration and rotation | Sensing tilt and turning |
| Wheel encoder | How much a wheel has turned | Estimating distance travelled |
| GPS | Position, outdoors | Navigating over large areas |
An ultrasonic sensor sends a pulse of sound and measures how long the echo takes to return. The sound travels to the obstacle and back, so the distance is half of what the sound covered:
d = (v × t) / 2 (v ≈ 343 m/s in air at about 20 °C)
Real measurements are never perfect: they contain noise, small random errors. A robot that reacts to every single reading would jitter. A simple remedy is to filter the readings, for example by averaging the latest few. Try it:
● raw readings ▬ filtered - - true distance
Experiment: raise the noise, then increase the averaging window. The blue line becomes smoother and closer to the truth. The price: a large window reacts more slowly when the real distance changes, so engineers always balance smoothness against reaction time.
4. Think: mapping, planning and deciding
With the data from its sensors, the robot's software has to answer three questions:
- Where am I? This is localization. The robot combines wheel encoders, inertial sensors and landmarks to estimate its position.
- What is around me? This is mapping. Many robots build a map while locating themselves, a technique called SLAM (simultaneous localization and mapping).
- How do I get there? This is path planning: finding a safe route from the current position to the goal.
Artificial intelligence plays a growing role in this step, for instance neural networks that recognize objects in camera images. But classic algorithms remain essential. A famous one is A* (pronounced "A star"). It scores each cell with
f(n) = g(n) + h(n)
where g is the cost already paid to reach cell n and h is a heuristic: an estimate of the remaining distance to the goal. Because of h, A* heads toward the goal instead of exploring in every direction like the simpler breadth-first search (BFS). Compare them yourself. Click cells to add or remove walls (green is the start, red the goal):
cells examined chosen path
Experiment: run A* and BFS on the same map and compare the number of examined cells. Both find a shortest path, but A* usually examines fewer cells. Click "Clear walls" to see the gap clearly: with an open field, BFS spreads in every direction while A* heads almost straight to the goal. Then wall off the goal completely: the planner reports that no path exists, and a real robot would have to ask for help or pick another goal.
5. Act: motors and control
The plan says "go to this point". An actuator, usually an electric motor, must make it happen. But motors never do exactly what is asked: wheels slip, batteries weaken, floors are uneven. So the robot closes the loop again, this time at low level, with a controller that compares what it wants with what it measures.
The simplest controller is proportional (P) control: the correction is proportional to the error.
u = Kp × e (e = target − measured)
The gain Kp sets how strongly the robot reacts. Too small and it corrects slowly. Too large and it overshoots, swings around the target and can become unstable. Most real robots add an integral and a derivative term, which gives the famous PID controller. The demo below shows a robot starting 1 unit away from its line, with a one-step delay in its reaction:
Slide the gain from low to high. Around 0.2 the error shrinks smoothly. Between roughly 0.3 and 1 it overshoots but settles. Beyond 1 it grows without limit: the robot would run off its line. This is a simplified model, but the same trade-off appears in real motors and steering systems.
6. Putting it together in code
All the pieces above fit into a program that repeats the loop. Here is the idea in Python (pseudo-code for a small wheeled robot with a distance sensor; the function names depend on your hardware library):
while True:
distance = read_distance_sensor() # 1. SENSE
if distance < 20: # 2. THINK
command = "turn_left"
else:
command = "go_forward"
drive(command) # 3. ACT
wait(0.05) # repeat about 20 times per second
Real robots add filtering, maps, planners and safety checks, and often rely on frameworks such as ROS (Robot Operating System) to connect these parts. But the skeleton is always this loop. If you have not written Python yet, start with Write Your First Python Program.
7. Limits and safety
- The real world is messy. Lighting, reflections, weather and unexpected objects can fool sensors and software.
- Uncertainty is permanent. The robot never knows its position exactly; it only has estimates, which is why good designs keep checking and correcting them.
- Rare situations exist. A robot can face a case its designers never imagined.
- Safety comes first. Serious robots include emergency stops, speed limits near people, sensor redundancy and human supervision.
8. Practice exercises
Complete each sentence, then check your answer. The feedback explains the solution.
9. Final quiz: test what you learned
Ten questions, one correct answer each. You get instant grading and every answer is explained.
Key takeaways
- An autonomous robot chooses its own actions from sensor data to reach a goal.
- It repeats the loop sense, think, act many times per second.
- Sensor readings contain noise, so robots filter them.
- Thinking includes localization, mapping and path planning, for example with A*.
- Controllers such as P and PID turn plans into smooth motor commands.
- Real robots must be designed for uncertainty, rare cases and safety.
Frequently asked questions
What is the difference between an autonomous robot and an automatic machine?
An automatic machine repeats a fixed program, usually in a controlled setting. An autonomous robot senses its surroundings and adapts its actions to reach a goal, even when the situation changes.
Do autonomous robots use artificial intelligence?
Often, but not always. AI methods such as neural networks help with tasks like recognizing objects in images. Many parts of a robot, such as path planning and motor control, use classic algorithms that are not machine learning.
What sensors does an autonomous robot need?
It depends on the task. A small indoor robot may only need distance sensors and wheel encoders. A self-driving vehicle combines cameras, lidar, radar, an inertial unit and GPS.
What is SLAM?
SLAM stands for simultaneous localization and mapping. It lets a robot build a map of an unknown place while estimating its own position inside that map.
How can I start building a simple autonomous robot?
Begin with a small wheeled kit, a microcontroller or single-board computer, and a distance sensor. Program the sense, think, act loop in Python, then add features one at a time, always testing safely.
Try changing the rules of the sense, think, act loop in your head: what should the robot do when the distance sensor returns nothing? Then keep learning with the other lessons, and get comfortable with code in Write Your First Python Program.
Definitions
Autonomous robot
A robot that chooses its own actions to reach a goal, using sensor data, without a human controlling every move.
Sensor
A device that turns a physical quantity, such as distance or light, into a number a computer can use.
Actuator
A part that produces motion or force, such as an electric motor.
Noise
Small random errors present in every real measurement.
Localization
Estimating the robot's position in its environment.
Path planning
Computing a safe route from the current position to a goal.
Control loop
A cycle in which the robot compares what it wants with what it measures and corrects the difference.
Common mistakes to avoid
- Reacting to every single noisy sensor reading without filtering
- Forgetting that ultrasonic distance is half of the sound's round trip
- Setting a controller gain so high that the robot oscillates
- Assuming the robot knows its exact position instead of an estimate
- Testing a robot's movement before making sure it can stop safely
- Thinking every autonomous robot uses machine learning
Practice exercises
Sense, think or act?
Classify each as sense, think or act: (a) measuring a distance, (b) choosing a route, (c) spinning the wheels, (d) reading wheel rotation.
Hint: Sensing collects data, thinking decides, acting moves.
Show solution
(a) sense, (b) think, (c) act, (d) sense.
Echo to distance
An ultrasonic sensor measures an echo time of 11.7 ms. Find the distance to the obstacle (speed of sound 343 m/s).
Hint: Divide the round trip by 2.
Show solution
d = 343 x 0.0117 / 2 = about 2.0 m.
Tune the gain
A robot swings left and right around its line and the swings grow larger. Should you raise or lower K_p, and why?
Hint: Growing swings mean the reaction is too strong.
Show solution
Lower K_p. A too strong correction overshoots the target and can make the error grow.
Key takeaways
- Thinking includes localization, mapping and path planning such as A*