Need help with my Project (Self-Balancing Bicycle)

I am currently working on a self-balancing bicycle project using MPU6050 sensor. I am finished with controlling the movements of my bike; forward, backward, left and right. The problem is the Balancing where i will be using the Tilt angle read by the accelerometer to be fed to my Gear/Motor that has Reaction wheel to be used to balance my bike using torque.

I have a code on a 2 wheeled balancing robot that I found on the internet; i will place it bellow.. Can anyone tell me if I can modify this code for my Self-balancing bike? if Yes, please help me modifying this.. Thanks

BButil.h (138 Bytes)

GyroStablization.ino (8.83 KB)

helper_3dmath.h (6.47 KB)

I2Cdev.h (11.8 KB)

MPU6050_6Axis_MotionApps20.h (39.7 KB)

Your project is very ambitious, and it can't be based on the 2 wheeled balancing robot code.

Did you ever try to ride a bike yourself, and keep it stand still? If it tilts, you'll have to drive a curve and move forward or back, until the bike is upright again. For this purpose you'll have to control the steering angle and the bike speed, while the 2-wheel robot controls the speed of two wheels. That's a very different control model.

DrDiettrich:
Your project is very ambitious, and it can't be based on the 2 wheeled balancing robot code.

Did you ever try to ride a bike yourself, and keep it stand still? If it tilts, you'll have to drive a curve and move forward or back, until the bike is upright again. For this purpose you'll have to control the steering angle and the bike speed, while the 2-wheel robot controls the speed of two wheels. That's a very different control model.

i ddn't mean a literal bike. i would just like to make a prototype. and example could be this:
https://www.youtube.com/watch?v=WlqR8xeOhow (credits to TOPTHL)

yes, i know they're 2 different ideas, but both uses MPU6050 and Kalman Filtering with the same Idea (Inverted Pendulum).. so therefore the codes i sent can't be modified for my SELF-BALANCING BICYCLE?

You have posted about 70k of code. Do you seriously expect someone to study all that? As well as which you accompany it with 5 lines of text. You have been working with it for weeks and you don't yet know what it does :slight_smile:

Have you made a simple balancing robot so you have some programming and tuning experience under your belt? This robot Post may be of interest

...R

I wonder how the bike is stabilized while standing still. Is this achieved with the propeller, or by moving a hidden mass?