Build a Room Coverage Robot That Sweeps a Floor
A robot that covers a room on its own with nothing but two bump switches — and a measured case for whether adding odometry and a planner is worth it.
What you are building
A robot whose job is not to get somewhere but to have been everywhere. That sounds like a smaller problem than navigation and it is a larger one, because there is no goal to steer toward and no way to tell from where you are standing whether you are winning.
It is also the project that most rewards measuring before building. The whole first half is a robot with two switches and no idea where it is, and it works — which is a genuinely uncomfortable discovery if you were about to spend a weekend on a map.
The number that runs the project
Floor area divided by the width of your brush is the distance a perfect robot would travel:
d_optimal = A / w
A 20 m² room and a 250 mm brush gives 80 m. Every strategy is judged as a multiple of that, and the multiples are not close together:
| Strategy | Distance to 90% | In that room, at 0.25 m/s |
|---|---|---|
| Perfect sweep | 1.0× | 5 min |
| Planned serpentine | 1.35× | 7 min |
| Random bounce | 2.9× | 15 min |
| Spiral and relocate | 5.5× | 30 min |
Those come from running the coverage simulator over five rooms. Before buying anything, run it yourself and drag the furniture around while it goes — the numbers move with the room, which is most of the lesson.
Bill of materials
| Part | Qty | Approx. cost | Notes |
|---|---|---|---|
| Arduino Uno | 1 | $5–8 | The random-bounce mode needs almost nothing; the planned sweep needs the encoders |
| Bump switches | 2 | $1 | Left and right, behind a wrapped shell. The primary sensor here |
| IR reflectance array | 1 | $5 | Cliff detection — pointed down at the floor edge, not at a line |
| N20 encoder motors | 2 | $16 | Required for the planned sweep; the random walk works without them |
| TB6612FNG | 1 | $3 | |
| 2WD chassis | 1 | $10 | Round is better than square here — it does not wedge in corners |
| Battery pack | 1 | $8 | Coverage runs are long; capacity matters more than on other builds |
Total: roughly $50–65.
This is the one project on the site where the cheapest sensor is the main one. Two bump switches and a random turn will cover an entire room given enough time — which is exactly how the first generation of robot vacuums worked, and it is worth building before reaching for anything cleverer.
The IR array is used unusually here: pointed downward at the floor as a cliff sensor rather than forward at a line. A robot that covers a room will find the top of the stairs.
Build order
1 — Race the strategies in the simulator. An hour here saves a weekend. Watch the coverage curve flatten and notice that all three strategies are identical for the first half of the floor.
2 — Build the drivetrain and the bumper, and nothing else. Two lever microswitches behind a sprung shell that wraps round to at least 45° each side, wired normally-open to ground with the internal pull-ups on. Debounce them properly — one press is nine edges, and an interrupt that counts will report a collision nine times.
3 — Add the cliff sensors before the robot ever runs unattended. Downward reflectance sensors at the front corners, read every pass. Then work out how fast you are allowed to drive: latency times speed, plus v²/2µg of braking, has to fit in the distance between seeing the drop and reaching it.
4 — Write random bounce and let it run for an hour. Drive straight; on a bump, reverse briefly and turn a random amount between 90° and 270°. The randomness is load-bearing — a fixed reflection angle turns the room into a billiard table and the robot traces a closed path forever.
5 — Measure it. Chalk or tape a grid on the floor, run it for a fixed time, and count squares. This is the baseline, and it is the only honest way to know whether step 6 is worth anything to you.
6 — Only now, add odometry. Encoders and differential-drive odometry give you a position estimate. Plan serpentine rows one brush width apart, minus 10–20% overlap, and route around furniture rather than into it.
7 — Watch the rows stop being parallel. They will, within about ten of them, because odometry drifts. That is not a bug in your planner; it is the reason commercial machines carry a gyro, a ceiling camera or a beacon. Deciding whether to add one is the real end of this project.
Hardware notes that matter
Round chassis, wheels on the diameter. A circular robot can always rotate out of a collision it drove into. A square one can wedge itself into a corner diagonally and needs a rear bumper and extra behaviour to escape.
The brush must be wider than the robot. This is not decoration. A planner keeps the body clear of every wall, so anything the body cannot reach is floor that never gets covered — in the simulator, 130 of the 133 squares the planner misses are within two cells of a wall or a table leg. An overhanging brush is what recovers them.
Two bumper halves, not one. A single switch tells you that you hit something. Two tell you which side, which is the information the turn direction needs, and it costs one pin.
Budget the battery in metres, not minutes. An hour at 0.25 m/s is 900 m. One room at random bounce is around 540 m to 99%. Three rooms is not happening, and that arithmetic — not any algorithmic insight — is what pushed the whole product category toward mapping.
What good looks like
Coverage is one of the few robot behaviours with a clean, single number attached, and the comparison between strategies is dramatic:
| Strategy | Coverage after 1× the room’s area driven | After 3× | After 10× |
|---|---|---|---|
| Random bounce | ~35% | ~70% | ~93% |
| Spiral, then bounce | ~45% | ~78% | ~95% |
| Planned boustrophedon sweep | ~85% | ~99% | ~99% |
The shape of those columns is the whole lesson. Random bounce approaches full coverage asymptotically and never quite arrives — the last few percent take longer than the first ninety. A planned sweep gets there in roughly one pass and then has nothing left to do.
That is the difference between having memory and not having it, stated as a number.
| Measurement | Typical |
|---|---|
| Sweep line spacing | 80–90% of the robot’s effective width, so passes overlap |
| Heading drift over one 4 m pass | 3–8° without a gyro, under 2° with one |
| Position error after ten passes | 15–40 cm on odometry alone |
| Practical room size for pure odometry | Up to about 4 × 4 m before the sweep visibly skews |
The last row is the honest ceiling of this project. A planned sweep depends on knowing where you are, and odometry drifts without bound — so past about 4 m the parallel passes stop being parallel and gaps open up. That is not a tuning problem; it is why mapping exists.
When it goes wrong
| Symptom | Usually |
|---|---|
| Traces the same loop forever | Bounce angle is deterministic; make it random |
| Covers 90% quickly, then seems to stop | Working as designed — that is the exponential coverage curve |
| One bump counted several times | No debounce, or a window shorter than the 5 ms bounce |
| Drives off a step | Too fast for the cliff-sensor budget, or the loop is blocking |
| Rows drift out of parallel | Odometry, not the planner. Add a heading reference |
| Misses stripes between rows | Row spacing set to exactly the brush width with no overlap |
| Wedges itself in a corner | Square chassis, or no rear bumper |
| Never gets behind the sofa | The transit between row spans was never planned |
Six of those eight are sensing, mechanics or arithmetic rather than algorithm — the same distribution as the micromouse, and for the same reason.
For the reactive layer this shares with every other mobile robot, the obstacle-avoiding robot is the gentler build with most of the same hardware, and the reactive navigation path covers the sensing and behaviour underneath both.
Project roadmap
The build path
Follow the tech tree from parts to a robot that follows a taped line. Each node unlocks when its prerequisites are done, and your progress saves on this device.
0 / 18 done
Components
- ControllerArduino UnoThe forgiving 8-bit board most people meet robotics through.
- SensorLever MicroswitchThe one bit of sensing that tells a robot it has already hit something.
- SensorIR Reflectance Sensor ArrayA row of infrared eyes that tells a robot where the line is.
- ActuatorN20 Encoder GearmotorA metal-gearbox micro motor with an encoder on the back, so the robot knows how far it has actually gone.
- DriverTB6612FNG Motor DriverA MOSFET H-bridge that keeps the volts you actually paid for.
- Chassis2WD Robot ChassisThe deck two motors, a free caster, and your electronics all bolt onto.
- PowerRobot Battery & Power PackThe difference between a robot that runs and one that keeps resetting.
Tutorials in this path
- Intermediate · 30 minCoverage Path Planning: Sweep a Whole FloorWhy a robot with no map needs seven times the distance to finish the same room.
- Beginner · 25 minBump Sensors and Debouncing for Robot CollisionsOne press, nine transitions — and the interrupt counts every one of them.
- Intermediate · 25 minStopping at an Edge: Latency and Braking DistanceHow far a robot travels past the line it just saw, and the speed that makes it fit.
- Beginner · 17 min readRead Quadrature Encoders for Distance and SpeedTurn quadrature encoder pulses into reliable wheel direction, distance, and velocity measurements.
- Intermediate · 20 min readDifferential-Drive Odometry from Wheel EncodersIntegrate left and right wheel motion into a mobile robot pose, then identify and calibrate drift.
Practise before you wire
Tune it in the live simulator
The build path routes through a browser lab. Find gains that follow the track cleanly here, then transfer them to the real robot.
Frequently asked questions
Is this a robot vacuum?
It is the navigation half of one, which is the interesting half. Adding suction is a mechanical problem — a fan, a brush bar, a dust cup and considerably more battery — and it teaches nothing the coverage problem does not. Build it with a dry cloth or a duster on the underside and it genuinely cleans a hard floor, and every algorithm on it is the same one a commercial machine runs.
Why start with random bounce if a planned sweep is better?
Because random bounce works with sensing you can build in an afternoon, and because it gives you a measured baseline the planner has to beat. In the simulator, random reaches half the floor in the same distance a planner does — the gap only opens after that. If you build the planner first you will spend a weekend fighting odometry drift without ever knowing what it bought you.
How much does the planner actually gain?
Measured over five rooms in the lab: a planned sweep reaches 90 percent coverage in 1.35 times the theoretical minimum distance, random bounce needs 2.9 times, and a spiral strategy needs 5.5. In a 20 square metre room with a 250 mm brush at 0.25 m/s, that is 7 minutes against 15 against 30. The catch is that the planner never reaches 99 percent at all, because it keeps a safety margin away from every wall and table leg.
Do I need the encoders?
Not for the first robot — it has no use for them. They are on the parts list because the second half of the project needs them and because retrofitting encoders to a built chassis is far more annoying than fitting them at the start. Buy the motors with encoders, leave the wires unconnected, and pick them up when you get to the planned sweep.
What stops it falling down the stairs?
Downward reflectance sensors at the front corners, read on every pass of the loop, and a speed limit that comes out of arithmetic rather than taste. The robot travels its own latency times its speed before braking even begins, then a braking distance of v squared over twice mu g. Both terms have to fit inside the distance between where the sensor sees the drop and where the wheels reach it.
Why a round chassis?
Because a circular robot's footprint does not change as it rotates, so it can always turn on the spot out of a collision it has driven into. A square robot wedged diagonally into a corner has to reverse first, which needs a rear bumper and more behaviour. It is the same reason nearly every commercial floor robot is round.