Self-balancing robot

Posted on August 1, 2020 by Zach Lambert ‐ 2 min read

Self-balancing robot

This robot was made up of the following components:

  • A 3d-printed chassis, with three levels connected by standoffs.
  • Two brushless motors with velocity feedback.
  • A base pcb using an AtMega328 microcontroller that interfaced with the motors and sensors
  • A top pcb, that provided an lcd display and buttons for reconfiguring parameters on the fly
  • A radio module, with an accompanying radio remote control, to provide velocity commands.

The code is here. The logic consisted of:

  • A control loop that used a state-space model of the dynamics.
  • Output commands for the brushless motor controllers.
  • Input feedback from a gyroscope for angular velocity, an accelerometer for tilt and joint encoders for velocity feedback.
  • Input commands over radio, to move the robot with a particular velocity.
  • Reading input from and displaying information on the top pcb.

By reconfiguring the controller parameters on the fly, a suitable set of parameters were obtained to balance the robot.

Following this, I investigated adapting the controller to correct for tilt biases. Before this, the bias was measured by assuming the robot was upright when it was turned on. The bias was corrected for by including it as part of the state.

Finally, I had a go at performing system identification to get the dynamic parameters and using LQR to obtain the gain matrix, but this didn’t end up working well. My guess is that the system identification was inaccurate.

I’ve collected a few videos I took below.

Final result

Balancing in place

Bias correction

Setting parameters