Finite State Machine
718 words · 4 min read · 2 sources
A finite state machine is a model in which a robot is always in exactly one state out of a fixed list — charging, delivering, idle — and moves to another state only when a named input or event triggers a transition.
A finite state machine says a robot is always in exactly one state from a fixed list, and only moves to another state when something specific happens. You can draw the whole design on one page as boxes with labelled arrows between them, which is why it is usually the first way anyone structures a robot's decisions.
🤯 A finite state machine has strictly less computational power than a Turing machine, because its only memory is which state it is in — so a machine with five states can never count to a thousand.
🎯 Quick challenge
In a finite state machine, how many states can a robot be in at once?
A finite state machine (FSM) is a model in which a robot is always in exactly one state out of a fixed list — charging, delivering, idle — and moves to another state only when a named input or event triggers a transition. It is a model of computation from automata theory, and the usual first way anyone structures a robot's decisions.
How it works
An FSM is fully defined by three things: its states, its initial state, and the inputs that trigger each transition between states.
The textbook example is a turnstile: two states, Locked and Unlocked, and two inputs, coin and push. A coin unlocks it; a push through locks it again. Nothing else can happen — and that is the point, because the whole design fits in a small table.
| Current state | Input | Next state |
|---|---|---|
| Locked | coin | Unlocked |
| Locked | push | Locked |
| Unlocked | coin | Unlocked |
| Unlocked | push | Locked |
That is a state-transition table. Drawn as a picture it becomes a state diagram: states are nodes, transitions are labelled arrows, and the starting state is marked by an arrow from a black dot. Seeing the whole design at a glance is most of why engineers reach for FSMs.
A machine is deterministic when every state-and-input pair has exactly one transition, and nondeterministic when an input may lead to zero, one or several. Two conventions exist for output: a Moore machine's output depends only on its state, while a Mealy machine's depends on the state and the input — which often means fewer states.
A worked example: the battery runs low mid-delivery
A robot is carrying a parcel across a hospital when its battery drops below ten per cent.
In an FSM you must say exactly where that can happen. Add a Charging state, then draw a battery low transition into it from every state the robot might be in when it notices — Delivering, Returning, Idle — each with its own answer to "what about the parcel?", plus a way back out again.
That is the cost people run into: add a lost the map condition next week and you draw another fan of arrows across the same states. Nav2's documentation puts the end point plainly — a finite state machine can need dozens of states and hundreds of transitions, which gets hard to manage. Hence the navigation stack is built on behaviour trees, where a new condition is one branch rather than one arrow per state.
Where you'll see it
Vending machines, elevators, traffic lights and combination locks are all FSMs, and so are compilers, network protocols and digital hardware. In robotics they are the standard shape for safety and operating modes — manual, automatic, emergency stop — where the states genuinely are few, fixed and mutually exclusive.
They also scale up rather than being replaced outright: UML state machines extend the plain model with nested states and parallel regions, the idea behind hierarchical state machines. Nav2 notes that a hierarchical-FSM navigator could be added alongside its behaviour-tree one if there is demand.
Why it matters
The FSM is how you learn to think about robot control at all: discrete modes, explicit triggers, one thing at a time. If you can draw your robot's behaviour on a napkin, an FSM will be clearer and easier to debug than anything else — including the mode logic wrapped around path planning in ROS 2. If the napkin is already full of arrows, look at a tree.
Common questions
Can a robot be in two states at once?
Not in a plain FSM — it is in exactly one state at any given time. Hierarchical and UML-style state machines add parallel regions to get around this, which is one of the ways designs grow complicated.
Is an FSM obsolete now that behaviour trees exist?
No. Trees earn their keep on long, failure-prone tasks; FSMs stay the clearest choice for small, fixed sets of modes, and are still everywhere in industrial automation and digital hardware.
Next step: read behaviour trees — how robotics structures decisions once a state machine's arrows get out of hand.
Next: one minute
Watch how Finite State Machine actually works
A one-minute video, an interactive demo you can poke at, and one question to check it landed.
Watch the one-minute lesson →Plain English. Free. Unsubscribe in one click.
Keep going
Behaviour Trees
A behaviour tree is a way of organising a robot's decisions as a tree of small tasks, where a parent node repe…
ConceptNav2
Nav2 is the ROS 2 navigation stack — the batteries-included framework that takes a mobile robot from "go to th…
ConceptAdmittance Control
Admittance control lets a stiff, position-controlled robot behave as if it were soft — it senses contact force…
Last updated · 2026-11-08
Spotted something off? Report an error →