GyroBike

View previous topic View next topic Go down

GyroBike

Post by DanielLC on Wed Sep 21, 2016 3:53 pm



Normally, you balance a bike by steering. Unfortunately, this only works if it's moving. I designed a bike that balances with gyroscopic precession so that it can stay balanced while still. It's also strong enough to lift the bike up after it falls over. Unfortunately it doesn't balance that well while moving, but this is more a proof of concept, and a better design could switch to steering-based balance when it gets going.

The gyroscopes are normally held horizontally, and spin in opposite directions to counter each other out. To balance the bike, they tilt forward and backward, which forces the bike to tilt left or right by the principle of gyroscopic precession. This doesn't work if it gets tilted to far, but in that case the bike simply falls over, resets the gyroscopes, and then picks itself back up.

It's not overly difficult to knock the bike over, but if you hold Z it locks the gyroscopes to make it fall easily so you can watch it right itself.

Code:
//GyroBike by DanielLC
Val
{
    ENGINE(default=0,min=-1500,max=1500,step=1500)
    TILT(default=0,min=-60,max=60)
    TURN(default=180,min=170,max=190,step=2)
    N_GYRO_POWER(default=0,min=-100000,max=100000)
    S_GYRO_POWER(default=0,min=-100000,max=100000)
    LOCK(default=0,max=1,step=1)
}
Key
{
    0:ENGINE(step=1500)
    1:ENGINE(step=-1500)
    2:TURN(step=-2)
    3:TURN(step=2)
    4:LOCK(step=1)
}
Body {
    Core(){
 N:RudderF(option=1,angle=TURN){
            S:Trim(angle=90){
                W:Wheel(power=ENGINE){}
            }
        }
        S:Trim(angle=-90){
            E:Wheel(power=ENGINE){}
        }
 E:Frame(angle=80){}
 W:Frame(angle=80){}
 E:Frame(angle=-80){}
 W:Frame(angle=-80){}
        N:Wheel(power=N_GYRO_POWER,angle=TILT,name=N_GYRO){}
        S:Wheel(power=S_GYRO_POWER,angle=TILT,name=S_GYRO){}
    }
}
Lua {
    function onInit()
        resetTiltNegative = false;
        resetTiltPositive = false;
    end
    function OnFrame()
 out(0,_VZ());
 N_GYRO_POWER = 200*(400-_WY(N_GYRO));
 S_GYRO_POWER = 200*(-400-_WY(S_GYRO));
        if LOCK == 0 then
            if resetTiltNegative then
                TILT = TILT - 1.5;
                if TILT <= -59 then
                    resetTiltNegative = false;
                    TILT = -59;
                end
            elseif resetTiltPositive then
                TILT = TILT + 1.5;
                if TILT >= 59 then
                    resetTiltPositive = false;
                    TILT = 59;
                end
            else
                TILT = TILT*1.03 - 10*_EZ() - 0.1*(TURN-180)*_VZ() - 2*_WZ();
                if TILT <= -60 then
                    resetTiltPositive = true;
                elseif TILT >= 60 then
                    resetTiltNegative = true;
                end
            end
        end
    end
}

DanielLC
Tank
Tank

Posts : 78
Join date : 2010-10-23

View user profile

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum