Skip to content

Ball-Balancing Robot

An educational Raspberry Pi ball-balancing robot that uses camera vision and PID control to keep a ball centered on a platform tilted by servos.

  • Other
  • Open source
  • 3D printable

Suggested by Robotheca, created by @I-M-Robotics-Lab (opens in a new tab), from github.com/I-M-Robotics-Lab/Ball-Balancing-Robot (opens in a new tab). Pinned to commit d06e5fd (opens in a new tab).

Hardware license
GPL-3.0-only (opens in a new tab)
Software license
GPL-3.0-only (opens in a new tab)
Commercial use
Allowed

This repository contains executable files that Robotheca doesn't check. Only run them if you trust the creator.

Which files (2 scripts)

Photo and 3D model

Ball-Balancing Robot, photo from its repository
Photo:@I-M-Robotics-Lab (opens in a new tab)GPL-3.0-onlysource file (opens in a new tab)

3D preview converted from github.com/I-M-Robotics-Lab/Ball-Balancing-Robot at d06e5fd, under GPL-3.0-only. View the original files from GitHub (715 KB) (opens in a new tab)

What it can do

Written by Robotheca from the project's documents.

  • Balances a ball on a tilting platform using real-time camera vision feedback.
  • Runs a PID control loop at roughly 60 Hz frame capture, 50 Hz vision processing, and servo actuation.
  • Provides a curses-based HMI over SSH with jog controls and calibration tools.
  • Runs headless: video preview is disabled automatically while the control loop keeps working.
  • Uses JSON-driven configuration, with calibration values saved to config/calibration.json.

Bill of materials

This repository has no parts list Robotheca can read yet.

Build guide

The creator's steps, each with its instructions.

  1. 1Obtain components
  2. 2Print and assemble robot structure
  3. 3Flash Raspberry Pi OS
  4. 4Install electrical components
  5. 5Install software
  6. 6Initial calibration via HMI
  7. 7Zero pose capture
  8. 8Offset calibration
  9. 9Verification
  10. 10Run runtime control loop

The guide appears here as you scroll.

Guide by @I-M-Robotics-Lab (README.md), under GPL-3.0-only.

Wiring and electronics

Notes written by Robotheca from the project's documents.

Main parts

  • Raspberry Pi as the main controller.
  • Camera module connected to the Pi's CSI connector.
  • PCA9685 I2C servo driver board.
  • Servos that tilt the platform through linkages.
  • Separate power supply for the servos.

Connections

  • Camera connects to the Pi's CSI connector.
  • PCA9685 connects to the Pi over I2C (SDA/SCL), typically at address 0x40.
  • Servo power is isolated from the Pi 5V rail (recommended).
  • Servo supply and Pi share a common ground.