State Machine: How a Robot Decides What to Do Next
A robot is always in exactly one mode, and a few simple rules decide when it switches to another. That is a state machine.
The robot repeats this loop many times a second. Tap a step to pause on it.
Think of a robot vacuum. It is cleaning, or searching for the dock, or charging, or stuck. Each of those is a state. At any moment it is in exactly one.
Transitions are the rules for changing state: "battery low, so go to the dock" or "bumper pressed, so back up". Drawing the states and arrows on paper before coding makes behaviour easy to check.
Behaviour stays predictable. You can test each state alone, and you can see every way the robot can get from one to another.
The code turns into a tangle of "if this and that and not the other", and the robot ends up doing two things at once or getting stuck.
With many states and many transitions the diagram becomes huge. Bigger robots often move to behaviour trees or layered state machines.
How many states is a state machine in at one moment?
Go deeper in the Atlas
Control and Balance
- Feedback Control Explained
- Line Follower Robot
- Why You Don't Fall in a Moving Bus (And Robots Do)
- How Boston Dynamics Robots Keep Their Balance
- How Drones Stay Level in Strong Wind
- PID Controller in 60 Seconds
- ROS 2
- How Robots Learn to Walk
- A* Pathfinding
- State Machine
- Robot Latency
- Reward Hacking
- Sim to Real
- How Humanoid Robots Walk Without Falling (ZMP Explained)
- Gain and Damping
- How Self-Driving Cars Think
- Swarm Robotics
- Robot Dog (Quadruped) Explained
- How a Drone Hovers
- Behavior Tree