For more detailed buid instructions refer to my blog
The robot can balance itself on two wheels and can handle small disturbance. Further work shall be done on remote controlling to move it.
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".
Refer to motor.h. Leonardo Serial1 is used to connect the Bluetooth.
MPU6050 lib from i2cdevlib and arduino-pinchangeint. You need to place the libs in the ~/sketchbook/libraries/ folder
-
Kalman filter: to fuse the data from accerometer and gyro and output angle. The implementation is referenced from TKJElectronics's Balanduino.
-
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.
-
Tune PID via Bluetooth: I downloaded BlueTerm to pair and communicate with arduino. Can Tune the PID without wire.
-
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.
-
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"
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.