GPGeorge Partridge
Contents

4-Wheel Differential Swerve Robot

A 3D-printed robot where every wheel steers and drives through a two-motor ring-gear differential. It runs on two PCBs I designed, and it uses LiDAR and a camera to find people and drive over to them.

The real robot finding me and driving over, next to the live page it serves over Wi-Fi (3x speed).
Swerve modules
4 two motors each
Custom PCBs
2 ESP32 + RP2040
Faults fixed
10 on hardware

Role Designer and builder: concept, design, printing, assembly, wiring, testing Timeline Oct to Nov 2026, ongoing Tools Fusion 360, KiCad, Python, C++, MicroPython, PyTorch

Each corner is a differential swerve module, where two N20 motors drive two stacked ring gears. Turn them together and the module steers. Turn them in opposite directions and the wheel drives. Both motors stay on the chassis, so a module can keep rotating forever without needing a slip ring.

System overview

Control architecture drawing: RPLIDAR, camera and tilt head feed the Raspberry Pi, which builds an obstacle map and a map of people, plans a route and sends commands to the ESP32 command guard and motor drivers. A red safety path goes from the raw scan straight to the command guard.
Control architecture. Sensors are on the left and motors on the right, and the dashed boxes show which chip runs what. Click to open it full size.

I wanted to get past simulation and FEA and have something real: a drivetrain I printed, running on a board I designed. The testing section lists everything I tested on it.

The hard problems

The biggest problem is that steering and driving are coupled. Every wheel movement is a mix of two motor speeds, so one geartrain has to give a useful steering speed and a useful wheel speed at the same time (gear ratios, torque). On top of that, nothing holds the steering angle. There's no steering encoder, so the robot works out the wheel angle from motor timing plus a hall-sensor check, and the wheels drift. The simulator assumes about 3° a second. On the real robot, one wheel swung 45° in a single turn (fault log).

Then there's the fact that the gears are printed. They're 1 mm module PLA teeth, and they have to survive a jammed module with both motors stalled (tooth strength). Getting eight motors, two boards, a Pi, a LiDAR and a battery into a 352 mm chassis that's bigger than my print bed, without any wires crossing a steering joint, took a lot of iterations. And the electronics kept dying. I had four driver or board failures in two weeks before I added hard firmware limits and sorted out the wiring.

The software runs on three chips. The Pi 5 reads the LiDAR and camera, builds an obstacle map and a map of people, plans a route, and picks a driving direction by sweeping the robot’s footprint along each option. The ESP32 runs the eight motors with timed steering and checks every command against hard limits. The RP2040 holds the camera’s tilt angle using an AS5600 sensor. The red path in the drawing is the safety layer. It reads the raw LiDAR scan rather than the map, and goes straight to the motor controller.

Mechanical configuration

The robot is 352 mm across. It has four identical swerve modules in a printed clover-shaped chassis, a centre bay for the battery, controller board and Pi, a centre cap that carries the RPLIDAR C1, and a camera tilt head on one corner.

Exploded view of the whole robot from Fusion 360 with numbered part callouts: LiDAR, centre cap, Pi and controller board, electronics tray, battery cradle, the frame, four swerve modules and the camera tilt head
Exploded view of the whole robot, generated from the Fusion assembly.
Parts list (11 assemblies)
No.Assembly
1LiDAR
2Centre cap P27
3Pi 5 + controller board
4Electronics tray P06
5Battery cradle P07
6Frame P02 (x4)
7Swerve module 1
8Swerve module 2
9Swerve module 3
10Swerve module 4
11Camera tilt head

Mechanical design

I modelled the whole thing in Fusion 360. It's 139 components: 27 custom printed parts (most used several times) plus reference models of every bought part, so I could check fits and wire routes before printing anything. Every part is jointed and has a part number and version (P13 ring gear, P27 v16 centre cap), which keeps the print files, the model and this page in sync. Here's the current assembly, as of November:

Design constraints

Every wheel had to steer and drive, so it could point in any direction while rolling. I didn't want a slip ring, so both motors stay fixed to the chassis and a module can spin forever without twisting any wires. Everything also had to be printable. The robot is bigger than my bed, so the chassis comes in pieces, and every gear is 1 mm module PLA. I also wanted to be able to plug in the Pi's USB, the ESP32's USB-C and the power without taking anything apart. The targets were 1 m/s cruise, 1 m/s² acceleration and a 180° module turn in 0.3 s (design targets).

The differential swerve module

All four corners use the same module. Two large ring gears (P13) sit one above the other. Each has 112 teeth round the outside for its motor pinion and 92 teeth on its face that mesh with the axle gear. When both rings turn the same way, they carry the axle gear round without spinning it, so the module steers. When they turn opposite ways, the axle gear spins and the wheel drives.

Same direction: steer Axle gear is carried round, wheel yaws Top ring gear Bottom ring gear Pinion Pinion Axle gear Wheel Opposite directions: drive Axle gear spins, wheel rolls Top ring gear Bottom ring gear Pinion Pinion Axle gear Wheel
One module from the side. The orange arrows show which way each ring turns.
CAD of one swerve module with the covers hidden: two stacked red ring gears around the wheel, the two motors with their pinions, and the bearing brackets holding the axle
CAD One module with the covers hidden. The two ring gears are stacked around the wheel, each ring has its own motor and pinion, and the bearing brackets carry the axle.

Each motor drives its ring through a 15-tooth pinion (a 7.47 : 1 reduction), and each ring face drives the 16-tooth axle gear (a 5.75 : 1 step-up). The ratio maths, and why the reduction sits on the ring stage, is in gear ratios.

The wheel axle runs in two printed bearing brackets (P12) bolted to the swerve base (P11), so when both rings turn together the whole wheel assembly gets carried round. The stacked ring gears run on their own bearing surfaces, which you can see cut in the section below.

Exploded view of one swerve module with numbered callouts: top cover, inner frame, two ring gears, two pinions, two N20 motors, bearing brackets, axle gear, end cap, wheel and hub, swerve base, hall sensor fixture and bottom base
Exploded view of one swerve module.
Parts list (13 parts)
No.Part
1Top cover P04
2Inner frame P03
3Upper ring gear P13
4Lower ring gear P13
5Motor pinion P14 (x2)
6N20 motors (x2)
7Bearing brackets P12 (x2)
8Axle gear P15
9Axle end cap P16
10Wheel, hex hub, insert, spacer P17-19
11Swerve base P11
12Hall sensor fixture P09
13Bottom base P01
Section view cut through the middle of a swerve module, showing the wheel and hex hub in hatching and the two stacked ring gears cut on either side
Section through the middle of the module. The wheel and hub are in the centre, with the stacked ring gears and their bearing surfaces cut on each side.

A couple of details came from printing. The pinions (P14, now v5) have a ribbed D-shaped bore that grips the N20 shaft without a grub screw, and I thinned their teeth by 0.15 mm so the mesh runs freely in PLA.

Chassis

At 352 mm across, the robot is bigger than my print bed, so I split the chassis into four identical frame pieces (P02) that join at the corners, with a four-piece bottom base (P01) underneath. The inner frames (P03) have ribs, cable ledges and vents. The top covers (P04) screw down into each ring hold-down, and corner brackets (P47) tie neighbouring covers and the frame joint together so the four quarters act as one stiff part.

Centre bay

Everything electrical lives in the middle, in three printed layers. The battery cradle (P07) at the bottom has a pocket for the in-line fuse next to the LiPo. The electronics tray (P06) above it holds the Pi 5 and my controller board, and it's left open under the board so the solder joints and connectors have room. The centre cap (P27) on top holds the LiDAR in a tapered well. It has honeycomb vents on the top and sides, plus windows lined up with the Pi’s USB, the ESP32’s USB-C and the power plug.

Section view cut through the whole robot, showing two wheels, the battery, controller board and Pi stacked in the centre bay under the cap
Section through the whole robot, with the battery, controller board and Pi stacked in the centre bay and a module on each side.

Camera tilt head

The camera sits on a head that tilts up and down, so the robot can look at someone’s feet when they’re close and their face when they’re across the room. The joint came out of my quasi-direct-drive gripper project. I took its printed planetary gearbox, resized it (4.8 : 1 instead of 6 : 1) and turned it into this tilt joint.

Exploded view of the camera tilt head along its tilt axis with numbered callouts: head mount, N20 motor, motor mount, sun gear, planet gears, housing with ring gear, planet carrier, bearing, camera cradle, camera, pivot pin, AS5600 sensor and tilt board
Exploded view of the camera tilt head along its tilt axis. Tap to open full size.
Parts list (13 parts)
No.Part
1Head mount P30
2N20 gear motor
3Motor mount P32
4Sun gear P34
5Planet gears P35 (x3)
6Housing + ring gear P31
7Planet carrier P33
86704 bearing
9Camera cradle P36
10IMX296 camera + lens
11Pivot pin P36b
12AS5600 sensor
13Tilt board + tray P43
The printed tilt head held in a hand, front cover off, showing the orange planet carrier with three cream planet gears inside the white ring gear, and the camera ribbon cable
The printed head with the cover off, showing the three planets around the sun inside the ring gear.

An N20 gear motor drives a 15-tooth sun gear. Three 21-tooth planets roll round a 57-tooth ring printed straight into the housing, and the planet carrier is the output (tilt ratio). The motor already has its own gearbox, so this stage isn't there for torque. It slows the head down for fine control and keeps the joint stiff. The sun’s bore has small ribs that grip the motor’s D-shaft, so it doesn't need a grub screw.

Camera, pivot and mount details

The camera is a global-shutter IMX296 with a 6 mm lens, screwed into a printed cradle on four M2 standoffs. The carrier, running in a 6704 bearing, turns the cradle from one side. On the other side a printed pivot pin locks into a hex socket in the cradle and turns in a printed bore. The pin carries a small magnet right in front of an AS5600 sensor, so the head always knows its real angle (about −28° to +58°) instead of guessing from motor time like the wheels do.

A printed mount bolts the head to one corner of the chassis and holds the AS5600 board on four screws with locators, so the sensor lines up with the magnet every time. Behind it, the tilt board clips into a tray. An RP2040-Zero on the board reads the sensor and runs the motor through a TB6612 module. The firmware caps the power at 6 V so the 6 V motor can’t be overdriven again (see fault log).

Materials

Every custom part is printed in PLA, gears included. The tooth-stress check gives a safety factor of 2.5 against PLA’s strength across its layers, so the gears don't need metal inserts. The mass budget treats the printed parts as solid (100 % infill), which makes it an upper bound.

Engineering calculations and validation

Before printing anything I wanted numbers. Everything below comes from my design script, swerve_design_calcs.py, which reads the tooth counts and part volumes from the final Fusion parameters. Anything I've called assumed or nominal still needs replacing with a real measurement.

Design targets

Design targets

Every other number comes from three targets. The RPLIDAR C1 scans at 10 Hz, so at 1 m/s the robot moves 10 cm between scans. I added 1 m/s² of acceleration and a 180° module turn in 0.3 s, which works out to 100 rpm at the module.

cruise v = 1 m/s  →  1 m/s ÷ 10 Hz = 10 cm between scans
acceleration a = 1 m/s²
steering: 180° in 0.3 s  →  100 rpm module speed

Gear ratios

CAD of the two stacked ring gears with a motor and 15-tooth pinion on each
CAD The 15 : 112 stage. Each motor’s pinion drives the outside of one ring.

Both motors feed both jobs, so one geartrain has to give a sensible steering speed and a sensible wheel speed at the same time. With every gear at 1 mm module the pinion sits 63.5 mm from the ring centre. Ignoring slip and backlash, with nA and nB as the two motor speeds:

iring = 112 / 15 = 7.47    iface = 92 / 16 = 5.75
ωwheel = 0.77 · (nA − nB) / 2    ωsteer = 0.134 · (nA + nB) / 2

So the wheel turns at 0.77× motor speed and the module steers at 0.134×. I put the reduction on the ring stage because that's the stage doing the steering, and the 92 : 16 step-up brings the wheel back up to a useful speed. The catch is that any mismatch between the two motors shows up as steering, which is exactly why the wheels drift.

Mass budget and wheel load

Mass budget and wheel load

Mass sets the force needed to accelerate and the grip at each tyre. For printed parts I took the CAD volume at solid PLA density (1.24 g/cm³), so it's an upper bound. Bought parts use nominal weights: 80 g of N20 motors, 140 g of wheels, 110 g for the RPLIDAR, 130 g for a ~1500 mAh 3S LiPo, 46 g for the Pi 5, 30 g for the ESP32 and controller, and 80 g of bearings, screws and wiring.

m = 431 + 490 + 85 + 616 g = 1.62 kg
Wwheel = m g ÷ 4 = 1.62 × 9.81 ÷ 4 = 4.0 N

That's 1.62 kg and 4.0 N per wheel, and the eight ring gears alone are about 200 g of it. Because it's an upper bound, the torque margins below are on the safe side.

PartMass
Chassis (bases, frames, covers)431 g
Swerve module printed parts, x4490 g
Centre bay (tray, battery frame, cap)85 g
Bought parts (motors, wheels, LiDAR, battery, Pi, controller, hardware)616 g
Total1.62 kg

Torque and speed

The motors are 12 V N20s rated at 1600 rpm no-load, on 75 mm wheels. There's no stall torque on the datasheet, so I assumed 105 mN·m, plus a rolling resistance of 0.03 and 60 % drivetrain efficiency.

F = m(a + Crrg) = 1.62 · (1.0 + 0.03 · 9.81) = 2.10 N
Tmotor = F r / 4 · 0.77 / 2 = 7.6 mN·m  (r = 37.5 mm)
nmotor = 331 rpm (cruise) + 747 rpm (steer) = 1077 rpm

7.6 mN·m is only 7 % of the assumed stall torque (12 % with losses), so torque isn't the problem. Speed is closer: cruising and steering together need 1077 rpm, 67 % of the rated 1600 (73 % of the 1480 rpm you get on an 11.1 V pack). The odd part is that at 1 m/s the motors run at only 21 % of no-load speed, which makes PWM control coarse. I kept the 1600 rpm N20s for this build. A 600 rpm N20 I modelled would cruise at about 55 % of its speed with roughly 2.7 times the torque.

Will printed teeth survive a stall?

FEA stress plots of the pinion and axle gear at stall
FEA Gear FEA at the assumed stall load. The peak is 12 MPa.

I didn't want the teeth to be the weak point, so I checked the worst case: a module jams and both motors stall. Using the assumed 105 mN·m stall torque, a Lewis form factor of 0.29, 7 mm face width and 1 mm module, with PLA at about 30 MPa across the layers and 50 MPa along them:

Ft = T / r = 0.105 N·m / 7.5 mm = 14 N
σLewis = Ft / (b m Y) = 14 / (7 · 1 · 0.29) = 6.9 MPa
SF = 30 MPa / 12 MPa (FEA peak) = 2.5

The FEA came out higher than the hand calc, at 12 MPa, because it picks up the stress concentration at the root fillet. That still leaves a safety factor of 2.5 in the weakest print direction and 4.2 along the layers. In practice the tyre gives up first anyway. At stall the wheel could push 7.3 N, but grip is only 0.8 × 4.0 = 3.2 N, so the full stall load only reaches the teeth if a module physically jams. That's why the gears are plain printed PLA with no metal inserts.

Structural FEA

Structural FEA

The bearing brackets (P12) and swerve base (P11) carry the wheel load into the chassis, so they have to survive bumps and drops. I loaded each module with 15 N, 3.8 times the static wheel load.

load factor = 15 N ÷ 4.0 N = 3.8
bearing bracket: peak 1.55 MPa, 0.008 mm deflection
swerve base: peak 0.82 MPa, 0.009 mm deflection

Both are far below what printed PLA can take, so they're overbuilt. I've left them as they are for now, but there's weight to take out later.

CAD of the printed bearing brackets bolted to the swerve base
CAD The bearing brackets (P12) on the swerve base (P11).
Stress plots of the bearing brackets and swerve base under a 15 N wheel load, mostly blue with small warmer areas at the screw points
FEA Bearing brackets and swerve base at 3.8 times the static load.
Tilt ratio and interference checks

Tilt head planetary ratio

The N20 already has its own gearbox, so this stage is for fine, stiff positioning rather than torque. The sun is driven, the ring is printed into the housing and the carrier is the output. It's the gripper gearbox, resized from 6 : 1:

i = 1 + zring ÷ zsun = 1 + 57 ÷ 15 = 4.8 : 1  (three 21-tooth planets)

Interference checks

I ran interference checks across the whole assembly every time a part changed. The only contacts left are deliberate ones, like screw threads in their holes and header pins in their sockets.

Electronics and control

The control system is split across three processors. The Pi 5 does perception and planning. The ESP32 on my controller board runs the eight motors and enforces the safety limits. Its command guard has a watchdog, holds long full-power pushes to 80 %, and makes every motor command time out on its own. The wheels have no steering encoders, so steering is timed, and each wheel gets re-checked against a hall sensor and magnet. Only the camera head has an absolute angle sensor (the AS5600). The Pi talks to the ESP32 over USB, and wheel angles and speeds come back over serial to the Pi’s position estimate.

The robot open on a bench with its top covers off: Raspberry Pi 5 and controller board in the centre bay, coloured wiring running out to each module, a soldering iron beside it
Photo Top covers off. The Pi 5 and controller board sit in the centre bay, with wiring out to all four modules.
The real robot from above: orange printed chassis, blue modules, the controller board and wiring in the centre
Photo With the cap off you can see the controller board and wiring in the centre bay.

Perfboard prototype

Before ordering a PCB, I proved one module on a hand-wired perfboard. It had an ESP32, one TB6612FNG driver, both motors for the module and the hall input, laid out hole by hole so the pin mapping matched the final PCB. The test firmware runs the motors at 20 kHz PWM (above hearing, so there's no whine), ramps the speed up instead of jumping (to full duty over 250 ms), stores calibration in flash and takes test commands over USB serial. The mixing function below is the core of it. After three bring-up faults the module drove and steered on command, which proved the differential drive worked on real hardware.

MixingsetModule
void setModule(int m, float drive, float steer) {
  // same sign on both rings = module spins in place
  // opposite signs = wheel drives, module stays pointed
  setMotorPct(2 * m,     drive + steer);
  setMotorPct(2 * m + 1, -drive + steer);
}

Each module is two motors. Same number on both rings and it steers. Equal and opposite and the wheel just drives.

Steering test: both rings turn together, so the module rotates in place.
Drive test: the rings turn in opposite directions, so the wheel drives straight.
Perfboard layout and wiring photos

Custom PCBs

Hand-wiring four drivers would have meant two stacked perfboards and dozens of solder links, so I designed a controller PCB in KiCad instead. It's 33 × 88 mm and two layers, with the ESP32, four TB6612FNG drivers for the eight motors, JST-PH sockets for the motors and hall sensors, and a 12 V input with bulk decoupling. I autorouted it with Freerouting, added ground pours and a motor-power pour, and checked every net against the firmware pin map. It passes DRC with zero errors and zero unconnected nets, and the USB port lines up with the slot in the printed cap. PCBWay made it with the drivers and passives already assembled, and I soldered on the sockets and plugs. I'm now designing a brushless successor, the Swerve HAT v3 (next board).

Board
33 × 88 mm, 2 layers
Motor drivers
4 TB6612FNG, 8 channels
Controller
ESP32 on headers
Design checks
0 DRC errors, 0 unconnected
Close-up of the top copper layer: four TB6612FNG driver footprints with their traces running to the motor and hall sockets
KiCad Top copper, close up, showing the TB6612FNG driver footprints and the traces between them. Click for the whole layer.
Close-up of the top of the board: motor sockets M1A to M4B, hall sensor sockets H1 to H4 and the bulk capacitor, with SWERVE GEORGE on the silkscreen
KiCad Motor sockets M1A–M4B, hall sockets H1–H4 and the bulk capacitor.
Close-up of the bottom copper layer: signal traces fanning out from the ESP32 header rows
KiCad Bottom copper, with the signal routing from the ESP32 headers.
Full copper layers, both sides, and the bay render

Here's each board as raytraced in KiCad’s 3D viewer, next to the real thing. The tilt-head board carries an RP2040-Zero and a TB6612FNG module for the camera.

3D render of the motor controller PCB at an angle, with JST sockets, four TB6612FNG drivers and the ESP32 header rows
KiCad render Motor controller v1.
Three manufactured green controller boards on a desk, silkscreened SWERVE GEORGE, one with the ESP32 fitted, with sockets and power leads soldered on
Photo The manufactured controller boards, with sockets and power leads soldered on.
3D render of the tilt head PCB with sockets for the RP2040-Zero and TB6612FNG module and JST plugs
KiCad render Tilt head board v1.
The tilt board installed in its printed tray on the robot: a blue RP2040-Zero and a red TB6612 motor driver module plugged into the carrier PCB, with wiring to the head
Photo The tilt board installed, with the RP2040-Zero and TB6612 module in the printed tray behind the head.

Software and autonomous navigation

Finding people runs on the real robot. The navigation tuning and the 200-room RL comparison come from my simulator, and I’ve also run the RL policy on the real robot.

Finding people

The camera tells the robot which direction a person is in, and the LiDAR tells it how far away the nearest thing is in that direction.

CameraIMX296, tilting YOLO11n detectorPi 5, ~17 fps Bearingfrom lens model LiDAR rangealong that bearing Person on mapmerge + confirm Plannerdrive to them
From a camera frame to a person on the map.

When it’s told to find people, the robot turns on the spot while a YOLO11n detector runs on the Pi 5 at about 17 frames a second. Each detection is a box in the picture. The lens model turns the box centre into a direction relative to the robot, and the LiDAR scan gives the distance along that direction. That point goes onto the live map as a person. It took a few fixes to get right (one person kept turning into several, see the fault log).

The five things I changed to stop it seeing ghosts

First, a sighting has to last. Someone only counts as found after about 0.7 s of pictures (12 frames at 17 fps), so one bad frame can't add a person. A new detection also joins an existing person if it's close on the map, or within 9° and at a similar distance, which fixed one person turning into several.

The edges of a wide lens bend too much to trust, so anyone more than 52° off the lens axis is ignored until the robot has turned towards them. To make the angle maths hold up, the camera measures its own lens. While the robot turns, it checks how far the picture slides for each degree of turn (the LiDAR gives the true angle), in the middle and near the edges. That gives a two-number lens model that works for normal, wide and fisheye lenses, so I can swap the lens without breaking anything.

The last fix was for people standing close. If the box is cut off at the top and bottom, the person is close, so a LiDAR hit far behind them (the wall) isn't taken as their distance.

Low obstacles from camera depth, in simulation

The camera also watches the floor for low obstacles the LiDAR’s scan plane misses (a shoe, a cable, a toy). A small depth network, MiDaS, estimates distance from a single frame. It works in the simulator, but on the real robot it's still the LiDAR safety layer that stops it.

Four panels: camera frames and depth estimates with low obstacles marked, from the depth obstacle watch
Depth obstacle watch output.

Navigation tuning in simulation

To tune the driving without wearing out the robot, I built a simulator that copies its flaws: wheels that drift 3° a second, steering that's timed rather than measured, and stops to re-check each wheel on its magnet. The real driving code runs against it unchanged. Here are 42 point-to-point trips across three simulated rooms, before and after a round of tuning:

Simulator: 42 point-to-point trips, three rooms
MeasureBeforeAfter
Average time per trip34.3 s30.0 s (12.5 % faster)
Average miss at the goal7.4 cm4.1 cm
Worst miss at the goal11.7 cm8.5 cm
Stops to re-check a wheel (about 5 s each)11870
Collisions00

Every change also has to pass 18 behaviour scenarios in the simulator (doorways, a 50 cm corridor, a U-shaped dead end, a person walking across, the LiDAR unplugged mid-drive). All the results are in the results section.

Hand-written planner vs reinforcement learning

Could a learned driver beat my hand-written planner? I trained a PPO policy in simulation and ran both through 200 random rooms behind the same safety layer.

Simulator: 200 random rooms, same safety layer
PlannerRL policy
Reached the goal94 %84.5 %
Median time to goal (rooms both finished)8.5 s7.6 s
Rooms where it passed closer than 3 cm031
Collisions00

The policy is about 11 % faster when both succeed, but it reaches the goal less often and cut within 3 cm of something in 31 rooms, so the hand-written planner stays in charge.

Training setup, example rooms and reasoning

I trained the policy with PPO, running 4,096 simulated robots at once for 131 million steps, which took roughly half an hour on a Hugging Face GPU. The simulator randomised rooms, wheel lag, slip, LiDAR noise and command delay so it couldn’t overfit one world. The policy sees 72 LiDAR ranges plus the goal, and outputs the same velocity command as the planner. Then both drove 200 random simulated rooms behind the same safety layer:

Four example rooms with the planner's blue path and the policy's orange path from start to goal
Four of the 200 rooms, with the planner in blue and the RL policy in orange.
Training curves: reward rising and the share of episodes ending in a collision falling from 40 % to 2.6 %
During training, crashes fall from 40 % to 2.6 % of episodes.

The policy is about 11 % faster when both succeed, but it reaches the goal less often and in 31 rooms it cut within 3 cm of something. The planner never came closer than 39 mm. I've since run the policy on the real robot as well, and it worked.

Prototyping and iteration

Most parts went through several versions once they met the real world, and two weeks of testing turned up ten real faults. I found them on the robot with a multimeter, screen recordings and the robot’s own logs.

Mechanical redesigns

PartChangeWhy
Module fixturesTwo internal fixtures became three, plus an internal railThe first print locked up as the bottom ring caught the top one, and motor wires could get pulled into the mesh
Motor pinion P14, v2 to v5Teeth thinned 0.15 mm, open top, ribbed D-bore with a lead-inA freer mesh in PLA, and a grip on the motor shaft with no grub screw
Centre cap P27, v8 to v1615 mm taller, wider walls, LiDAR well, honeycomb vents, port windows, stronger screw stripThe wiring didn't fit, the Pi needed air, and I wanted to plug in without opening it
Top cover P04, v3Screws into the ring hold-downThe covers needed to be tied to the structure, not just resting on it
Electronics tray P06 v8, battery cradle P07 v4Open under the controller board, fuse pocket, a fifth screwRoom for solder joints and the fuse, and a stiffer stack
Camera cradle P36, v5 to v7Refitted for the IMX296, screw holes turned 60° with 4 mm driver holesA screwdriver couldn't reach the original screws
Pivot pin P36b, v3 to v67.6 mm journal and a pocket for a round 5 × 2 mm magnetTo use the magnet I had for the angle sensor
Tilt board tray P43, v6Clips and solid pins instead of screwsQuicker to assemble and nothing to strip

Perfboard bring-up

Getting the single-module perfboard running meant chasing three faults: a USB-C power quirk, a solder bridge on the serial pins, and a resistor across the driver’s signal pins.

Fault log: what broke, and how I fixed it

The robot had ten faults in its first two weeks of testing. These three taught me the most:

Seven more faults, in date order
15 Nov · …and the replacement died toomultimeter diagnosis
Symptom
The head stopped moving both ways.
Diagnosis
With a multimeter, I found the battery, the supply at the driver and the control signals were all there, but nothing reached the motor plug.
Cause
The driver’s output stage was dead after many stalls at the 6 V limit.
Fix
I cut the stall stop to 0.4 s, added a 4 s cool-down between retries, made it give up after three stops, and fitted a replacement tilt board.
Result
I bench-tested the replacement from the Pi and recalibrated it on 21 Nov.
15 Nov · One person, seven peoplelens self-measure
Symptom
The live map listed seven people when only I was in the room.
Diagnosis
The camera picture showed the ceiling, a fan and a window at once.
Cause
The lens was far wider than the 45° the code assumed, so every frame put me in a different direction.
Fix
The camera now measures its own lens while the robot turns, using the LiDAR’s turn angle as the reference. A person has to be seen for 0.7 s before they count, and nearby sightings merge.
16 Nov · The motor drivers burned on the controller boardfirmware v7.4 limits
Symptom
During setup after a rebuild, the drivers on the main board burned out, which meant a new board and a new ESP32.
Cause
Most likely the ESP32 sat low enough to touch the drivers. Going through the firmware, I also found that a motor command with no time limit ran forever, and nothing limited a stalled motor at full power.
Fix
Firmware v7.4. Every motor command now ends by itself (30 s at most), long full-power pushes are held to 80 %, and the Pi stops when the wheels push but the LiDAR shows no movement.
19 Nov · Stuck beside a box for two minutessix causes in the code
Symptom
In a screen recording, 1.4 m from me, it kept stopping to re-check wheels that were only 7 to 9° out, and the planned route flipped between scans.
Cause
Six causes in the code, including a wheel re-check due every 4 s and a route planner that counted the stops for wheel checks as “not making progress”.
Fix
The robot now trusts the LiDAR’s position fix between checks, holds a direction while it’s still clear, stops counting wheel stops as lost time, and gives up after 45 s with no progress to try another side.
19 Nov · A flat battery that looked like a software buglow-battery note
Symptom
The next run went back and forth and gave up. The wheels pushed 35 cm but the robot only moved 7.
Cause
Nothing was wrong in the code. The battery was nearly flat.
Fix
The robot now notices when it makes under 55 % of the speed it should and says the battery is probably low.
19 Nov · The ESP32 didn’t start at power-onUSB restart
Symptom
“No ESP32 found”, even with only the ESP32 plugged in. Pressing its reset button brought it back.
Fix
The robot tool now restarts the ESP32 over USB, captures its start-up message and says exactly what’s wrong instead of guessing.
22 Nov · A dead hall socket, then a shortnew board
Symptom
Hall socket 4 stopped working (the sensor was fine in another socket).
Diagnosis
Its 5 V pin had no continuity, so the track was broken.
What went wrong next
My workaround moved the sensor to pin D15, but that pin is read at boot, so flashing failed. Later, a jumper near the 3V3 and GND header pins shorted them. The board scorched and two ESP32s died.
Fix
A new board and the original firmware.
Lesson
Measure resistance both ways before refitting an ESP32, and keep wires well away from the power pins.

Physical testing and results

Tested on the robot

  • All four modules driving and steering after the PCB build
  • Eight-step self-calibration (clips below)
  • Turning on the spot, scanning with the camera, marking each person on a live map and driving to them round furniture (video at the top)
  • Firmware command limits (v7.4) and the LiDAR safety layer
  • The RL policy driving the real robot (planner vs RL)
  • YOLO11n person detection at about 17 frames a second on the Pi 5
  • Camera tilt range about −28° to +58°, read from the AS5600
  • One module on the perfboard, before the PCB (perfboard)
  • Steering repeatability ±1.2°, 65 min battery runtime, 32 °C motors, 1.7 kg payload (results)

In simulation

  • Navigation tuning, 42 point-to-point trips (navigation results)
  • 18 behaviour scenarios
  • 24 random cluttered rooms with a realistic base (below)
  • Planner vs RL comparison over 200 rooms (planner vs RL)
  • Camera depth estimate for low obstacles (depth estimate)

Build and calibration on the real robot

With the PCB done, I printed and assembled the rest: four modules, the chassis, the centre bay with the Pi 5, the battery and the LiDAR, and the camera on its tilting head with its own RP2040 board. A robot that steers by timing has to be measured before it can drive, so the robot tool on the Pi walks through eight setup steps: motor and hall checks, steering direction, homing each wheel on its magnet, timing how fast each module steers, drive balance, floor checks with the LiDAR, and calibrating the tilt head. The clips below are from 18 and 21 November, filmed on my phone and sped up.

Uncut run, real time

Footage
Unedited phone video, 78 s at normal speed, 18 Nov
What happens
The robot turns on the spot, then drives across the living room. Partway through, someone walks past the camera and a box appears on the floor.
Why it’s here
The clip at the top of the page is sped up 3×. This one shows the real pace with no cuts.
Status
Tested on the robot

Performance results

Hardware measurements come first, then navigation results from my simulator (which copies the real base’s flaws: wheel drift, timed steering, magnet re-checks, LiDAR noise, wheel slip), then the design calculations.

MeasureResultSource
Steering repeatability at the magnet±1.2°Measured on the robot
Wheel drift between magnet checks5.1°Measured on the robot
Battery runtime65 min averageMeasured on the robot
Motor temperature32 °C after a full run (about 7 min, including the start-up calibration)Measured on the robot
Payload1.7 kg, adding weight until the robot’s agility and movement visibly changedMeasured on the robot
Point-to-point trips reaching the goal42 / 42, 0 collisionsSimulation, 3 rooms
Positioning accuracy at the goal4.1 cm average miss, 8.5 cm worstSimulation, tuned planner (navigation results)
Average time per trip30.0 sSimulation, tuned planner
Average progress speed0.16 m/s, with 61 % of the time driving and 33 % steeringSimulation, 42 trips
Random cluttered rooms, realistic base18 / 24 reached the goal, 0 collisions, closest pass 65 mmSimulation stress test (lag, 8 % slip, LiDAR smear)
Behaviour scenarios18 / 18 passedSimulation
Success rate over 200 random rooms94 % planner, 84.5 % RL policySimulation (planner vs RL)
Cruise speed1 m/s design target, 4.84 m/s at motor no-load speedDesign calculation (design targets, torque)

Conclusion and future development

Two months ago, all I had was one module turning on a perfboard. Now there’s a whole robot that calibrates itself, finds people and drives to them round furniture, with a LiDAR safety layer underneath that can stop the motors whatever the planner says.

Next I want to bring the camera’s depth estimate onto the robot for low obstacles the LiDAR can’t see, and build a Mk2 with brushless motors and a payload deck, starting with the new board below.

Next board: Swerve HAT v3 (brushless)

The Mk2 moves to brushless motors, so I’ve started the next PCB: a Raspberry Pi 5 HAT with eight three-phase brushless drivers and an encoder port for every motor, run by two ESP32-S3s. It’s still a draft. All 285 parts are placed, and routing is next.

KiCad 3D render of the Swerve HAT v3: green board with two ESP32-S3 modules, eight driver ICs with sense resistors, eight motor and eight encoder connectors, two bulk capacitors and a buzzer
KiCad render Swerve HAT v3, parts placed. The eight driver channels fill the lower half, and the two ESP32-S3 modules sit top right, with their antennas off the edge.
Format
Pi 5 HAT 85 × 112 mm, 4 layers
Motor drivers
8 DRV8313 three-phase
Current sense
0.1 Ω per driver
Controllers
2 ESP32-S3-WROOM-1
Feedback
8 encoder ports, 4 hall inputs
Sensing
INA226 power monitor, MPU-6500 IMU
Power in
3S via XT30, 15 A fuse, TVS
Status
Placed not yet routed
What changes from the board on the robot now
v1 (on the robot)v3 (in design)
Motors8 brushed N20s8 brushless, with encoders
Drivers4 × TB6612FNG (2 channels each)8 × DRV8313 with current sense
Controller1 × ESP322 × ESP32-S3
Board33 × 88 mm, 2 layers85 × 112 mm, 4 layers, mounts on the Pi 5
Power12 V input, bulk decouplingXT30 battery input, 15 A fuse, TVS, power monitoring
StatusBuilt and drivingParts placed, routing next
Placement drawing (copper pads and silkscreen)
Top-view placement drawing of the Swerve HAT v3 showing the Pi header, power section, two ESP32-S3 footprints and eight motor-driver channels
KiCad Top-side placement, with the Pi header along the top, power on the left, controllers on the right and the eight driver channels below.

How I used Claude

I wrote the code for this robot in tandem with Claude (Anthropic). I gave it my handwritten calculations and my original Python scripts, and set up a Claude skill to translate them into much more efficient, robust code. I then checked the code over myself. I modelled every part myself in Fusion, and Claude also helped check the PCBs.

The idea, the design decisions, the printing and assembly, the soldering, every test on the real robot and the measurements were mine.

Back to top