Balance Bot PyBullet Simulation - max-proj17/Robotics-Projects GitHub Wiki

Self-Balancing Robot Simulation

Overview

A minimal PyBullet simulation of a two-wheeled self-balancing robot. Two threads run:

  • sim_thread:

    1. Reads IMU orientation and gyro-rate from PyBullet
    2. Adds small noise to pitch
    3. Filters via Kalman1D and sends error to PID
    4. Commands wheel velocities to balance
  • plot_thread:

    1. Collects (time, raw_pitch, filtered_pitch, raw_rate, filtered_rate, control)
    2. Updates four live Matplotlib subplots (pitch, rate, PID output, ESS)

Quick Start

  1. Clone repo

    git clone <repo-url>
    cd <repo-folder>
  2. Install dependencies

    ./install.sh
  3. Run simulation

    python main.py
    • A PyBullet GUI window launches with three PID sliders (P_gain, I_gain, D_gain).
    • Adjust sliders to tune balance.
    • A separate Matplotlib window shows live data plots.

File Structure

.
├── controllers.py      # PID class
├── filters.py          # Kalman1D class
├── simulation.py       # setup_pybullet()
├── main.py             # sim_thread + plot_thread
├── balance_bot.urdf    # Robot URDF
├── requirements.txt    # Dependencies list
├── install.sh          # “pip install -r requirements.txt”
└── README.md           # (this file)

Notes

  • For detailed Kalman/PID code, see filters.py and controllers.py.
⚠️ **GitHub.com Fallback** ⚠️