Balancing Robot

My Balancing Robot using a RaspberryPi ModelB and a buch of Pololu Products.

12V NIMH Battery Pack
RaspberryPi B
Pololu 5V StepDown Regulator (forRPi)
37D MetalGearMotors 19:1 with encoders + Hubs + MountingBrackets
RoboClaw 15A
Custom Made Aluminum Chassis

State Measurement:
Position - Encoder (RoboClaw Feature)
Velocity - Encoder (RoboClaw Feature)
Angle - IMU (MinIMUv2 Accelerometer&Gyro Fusion)
Angular Velocity IMU (MinIMUv2 Gyro)

MotorController, PWM (RoboClaw Feature)

Software is written in C++. RPi runs a control loop at 50 Hz measuring all states, computing the control signal and sending it to the actuators.
The control signal is computed using LQR state-feedback. The resulting value is remapped, avoiding motor-deadzone issues.
Features for driving in a straight line and driving curves were added.
LQR gains were calculated numerically after having modeled the entire system.

Step stones:
-Compensating for the motors deadzone.
-Getting the correct motor parameters (Inductance, Resistance, Load Inertia, BackEmf, friction …).
Chosen strategy:

  1. Measurement of the motors step responses for different DutyCycles using the encoders.
  2. Creating a Motor model with initial guesses for the unknown parameters.
  3. Find Parameters using numerical optimization toolbox (sth. like octave or matlab)

ToDo: Bluetooth Interface to steer the robot via smartphone or pc.

1 Like


Cool balancing robot! Thanks for sharing. What RPi case are you using?


Hi Jon,
its this one just in black.

Made a video of it!


Are you willing to supply the code you developed for this project?

Of course I can. [wirnsei(at)] to contact me.

Hey, this is really cool balancing robot. Congrats!