[ODE] Bike Balancing!

Eike Decker eike at cube3d.de
Wed Nov 7 08:05:13 MST 2007

>From the sources I've read back then, it is the way how we stabilize the bike
when driving it - little steers to the left and right. One said that you can
see that if you drive slowly with wet wheels or on sand - one path is smooth,
which is the back wheel, and one path is oscillating around that smooth path,
which is your own stabilizing.

There's an article here which covers the balancing 

I've tried many things out, and adjusting the steering is enough to balance it.
And for a nearly upstanding bike, the sphere wheel geometry is not different
from real wheels. Without that stabilizing movements, the bike tips over very
quickly, thus, the spheres do not seem to stabilize the bike.

Thanks for explaining your tire physic model. I thought lately if I could use
some ray tests and using dcontact joints for simulating the tire physics. I
wouldn't want to make the slip/contactforce calculations myself...

Btw, putting the center of mass below the bike does help, but is also causing
troubles in certain conditions.


> Eike I suspect uch of the balancing behaviour that your experiencing is 
> from the sphere themselves?  Not sure if just altering the steering 
> angle will do what I want as I'm casting rays against the world for 
> wheel collisions.
> ----
> This is OT :- but maybe people here might benefit from how I approached 
> my tire model. Maybe I can be persuaded to do a ODE example when I have 
> some free time :)
> The tire model is very simplistic and comes in two parts :-
> 1) the engine/transmission simulation which deals with the torque/revs 
> of the engine and gearing
> 2) the forces produced by the tires
> The first part is just numbers, and not really that hard to do. It just 
> calculates the engine and rive torque bases on the throttle input and 
> current drive gear.
>  The second part really does nothing more than cast a ray for each wheel 
> against the scene.  When a wheel is colliding with something it produces 
> the wheels forces in this way :-
> 1) Caclulate the world matrix of the wheel (this will include any 
> steering angle on the wheel)
> 2) Project the wheel matrix on to the contact normal The At and Right 
> vectors of the matrix will now give you the longitudinal and lateral 
> force vectors
> 3) If the wheel is a drive wheel, calculate the desired force from the 
> drive torque and multiply this by the longitudinal patch vector from step 2
> 4) If the wheel is braking, then produce calculate the brake force 
> produced by the wheel
> 5) Get the velocity at the wheel contact point, and normalize it (call 
> this vector patchVel)
> 6) Perform a dot product between the patch vel and the patch right 
> vector and multiply this by the wheel load (I get this from the 
> suspension force) and also the tires friction coeffiicient.
> 7) Calculate the maximum load the tire can take.  I calculate this by 
> taking the wheel load (again from the spring force) and multiplying it 
> by the tire friction coefficient and the surface friction coefficient. 
> At this point you wil have three things :-
>  i. The desired longitudinal force of the tire ( a scalar value called 
> forceLong)
> ii. The desired lateral force of the tire ( a scalar value called forceLat)
> iii. The maximum force the tire can produce ( a scalar value forceMax)
> 8) Check to see if the tire is braking the force limits. If it does, 
> workout the total amout of force the tire produces and flag the wheel as 
> braking traction.  An exmaple of the code is :-
> forceMaxSqr = forceMax * forceMax;
> totalForceSqr = (forceLong*forceLong) + (forceLat*forceLat)
> if (forceMaxSqr < totalForceSqr)
> {
>     float k = totalForceSqr / forceMaxSqr
>     forceLong *= k;
>     forceLat *= k;
>    // You may want to set flags in your wheel structure to indicate the 
> wheel has lost traction
> }
> 9) Combine the forces into one vector with something like
> forceVec = (patchLat * forceLat) + (patchLong + forceLong)
> 10) Apply the force at the contact point for the wheel
> 11) Update your wheel rotation velocities.  It's a bit complicated to 
> explain everything I do here, but in a nut-shell; the wheel rotation 
> velocities are updated depending on thier drive/brake/traction state.  
> i.e. if a drive wheel is slipping, it's rotational velocity is that of 
> the rpm of the axle, if not, then it's the same as the longtudinal patch 
> velocity.  If the brakes are pressed and the wheel has lost traction, 
> then the angular velocity of the wheel is just assumed to be zero (locked)
> 11) There is also a feedback loop for the engine revs to be constrained 
> to the wheel rotations, but just taking the average of all of the drive 
> wheels rotational velocities in contact with the ground and not slipping.
> The tire model isn't complete though.  I haven't added 
> lateral/longitudinal tire deformation and the maximum force calculation 
> should really use something like Pacejka curves, but as a basic model it 
> works very well.  I prototyped the tire model using a car with similar 
> parameters to a Opel/Vauxhall/Holden VXR8 and it was pretty fun to drive.
> I added some additional things to the tire model for more arcade 
> handing. Things like :-
> i) simple/complex load calculation flag
> ii) simple/complex patch matrix calculation flag
> iii) fake global downforce multiplie which acted on the max force 
> calculation
> The car is pretty fun to drive and exibits very realistic behavours like 
> brake lock up, wheel spin, traction loss as the tires reach thier 
> limits.  The lack of tire deformation make loss of traction happen very 
> suddenly though, sort of like driving on very bad tires at high speed.
> It worked on the bike first time too using engine and gearing parameters 
> from a Yamaha, apart from the falling over bit :)
> I hope this was informative!

More information about the ODE mailing list