Balance Bot PyBullet Simulation - max-proj17/Robotics-Projects GitHub Wiki
A minimal PyBullet simulation of a two-wheeled self-balancing robot. Two threads run:
-
sim_thread:
- Reads IMU orientation and gyro-rate from PyBullet
- Adds small noise to pitch
- Filters via Kalman1D and sends error to PID
- Commands wheel velocities to balance
-
plot_thread:
- Collects (time, raw_pitch, filtered_pitch, raw_rate, filtered_rate, control)
- Updates four live Matplotlib subplots (pitch, rate, PID output, ESS)
-
Clone repo
git clone <repo-url> cd <repo-folder>
-
Install dependencies
./install.sh
-
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.
.
├── 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)
- For detailed Kalman/PID code, see
filters.py
andcontrollers.py
.