/balance_robot

Home-made self-balance robot

Primary LanguageJupyter NotebookGNU General Public License v2.0GPL-2.0

For more detailed buid instructions refer to my blog

Demo

The robot can balance itself on two wheels and can handle small disturbance. Further work shall be done on remote controlling to move it.

robot

Video: here

##Compilation Use CMake to compile the code

For Arduino Leonardo, I have to use the upload.py for uploading the binary. For other Arduino boards, use "make upload".

Hardwares

  1. Arduino Leonardo Board

  2. 2 DC Motors: JGA25-371 with encoders

  3. Arduino Motor Driver Shield

  4. 12V-5V-3.3V Power Convertion Board

  5. ZIPPY Flightmax 2200mAh 3S1P 25C Battery

  6. HC-06 BlueTooth Module

  7. MPU-6050 6DOF IMU

  8. Self designed 3D-printed robot structure

Pin Connection

Refer to motor.h. Leonardo Serial1 is used to connect the Bluetooth.

Dependency

MPU6050 lib from i2cdevlib and arduino-pinchangeint. You need to place the libs in the ~/sketchbook/libraries/ folder

Software Key Components

  1. Kalman filter: to fuse the data from accerometer and gyro and output angle. The implementation is referenced from TKJElectronics's Balanduino.

  2. PID control: "velocity" PID which can prevent integral windup (Further theory refer to this link). Target is to stablize the robot around angle 0. In this version of software I used a two-level controller to gain better performance.

  3. Tune PID via Bluetooth: I downloaded BlueTerm to pair and communicate with arduino. Can Tune the PID without wire.

  4. Motor control: control use PWM signal. The motor has a minimum PWM to be applied, because under certain minimum PWM value the motor does not move at all.

  5. Python Debug: python script analysis/serial_plot.py can plot the data from Serial port in real time. But the message has to follow the format "name\t value\t name\t value\t...\n"

Problem encountered

This motor can not supply enough torque when the robot deviate its angle too much, so the robot can still fall down when angle error is big.