AmpleRobots

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

ComponentQtyPurpose
Tall frame with two motor mounts1A higher centre of mass makes balancing slower and easier.
Stepper motors with drivers, or geared DC motors with encoders2Precise, responsive wheel control.
6-axis IMU (gyroscope + accelerometer)1Measures tilt angle and rate.
Microcontroller with a fixed-rate timer1Runs the control loop at a steady rate (e.g. 100–200 Hz).
Battery pack with protection1High current capacity for quick corrections.

Generic parts are listed on purpose: choose locally available equivalents that meet the same ratings.

Build steps

  1. Mount the IMU rigidly near the wheel axis and record its axis directions.
  2. Read raw data and calibrate the gyro offset with the robot still.
  3. Fuse gyro and accelerometer readings with a complementary filter to estimate tilt.
  4. Run the loop at a fixed rate and log tilt to check it is smooth before driving motors.
  5. Tune P until the robot reacts, then D to damp oscillation, then a small I to hold position.
  6. 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.

  1. Record balancing time from release, up to 5 minutes.
  2. Apply a light, repeatable push (e.g. a pendulum tap) and measure recovery time.
  3. 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 →