Robot Passport · Controls
Self-balancing robot
Keep an unstable robot upright with sensor fusion and fast control.
A two-wheel inverted-pendulum robot that fuses gyroscope and accelerometer data and balances with a PID loop.
What you will learn
- IMU sensor fusion
- Complementary filter
- Fast control loops
- Systematic PID tuning
Parts
| Component | Qty | Purpose |
|---|---|---|
| Tall frame with two motor mounts | 1 | A higher centre of mass makes balancing slower and easier. |
| Stepper motors with drivers, or geared DC motors with encoders | 2 | Precise, responsive wheel control. |
| 6-axis IMU (gyroscope + accelerometer) | 1 | Measures tilt angle and rate. |
| Microcontroller with a fixed-rate timer | 1 | Runs the control loop at a steady rate (e.g. 100–200 Hz). |
| Battery pack with protection | 1 | High current capacity for quick corrections. |
Generic parts are listed on purpose: choose locally available equivalents that meet the same ratings.
Build steps
- Mount the IMU rigidly near the wheel axis and record its axis directions.
- Read raw data and calibrate the gyro offset with the robot still.
- Fuse gyro and accelerometer readings with a complementary filter to estimate tilt.
- Run the loop at a fixed rate and log tilt to check it is smooth before driving motors.
- Tune P until the robot reacts, then D to damp oscillation, then a small I to hold position.
- Add a tilt cut-off that stops the motors if the robot falls past a safe angle.
Test protocol
Goal: Measure how long the robot balances and how it recovers from a push.
Setup: Flat floor, clear 2 m radius. Use a soft barrier or hold a tether.
- Record balancing time from release, up to 5 minutes.
- Apply a light, repeatable push (e.g. a pendulum tap) and measure recovery time.
- Repeat at two battery levels.
Record for every run:
- Balance time (s)
- Recovery time (s)
- Max tilt during recovery (°)
- PID gains
- Battery voltage (V)
Measured results for this reference design will be published here with their test conditions. Submitting your own results opens with member accounts.
Safety
- Always include a tilt cut-off.
- Test with a tether or soft barrier first.
- Protect batteries from impact when the robot falls.
Take it further
- Add remote control while balancing.
- Try an LQR controller and compare.
- Plot the step response from logged data.
Stuck on this build?
Ask the AmpleRobots team. Build threads in RoboForum, linked to each Passport, open with member accounts.
Ask a question →