How to make a bicycle lean into a curve?

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

How to make a bicycle lean into a curve?

Postby StormChild » Wed Apr 21, 2010 11:14 am

Hi folks,

like the subject suggests, I set up a bicycle composed of 4 parts (2 wheels, 1 part consisting of the handle bar and the front fork, last part consisting of the rear frame and the rear fork). Each parts has it's own body, three hinges are connecting the parts. Acceleration and steering of the bike works quite well I think, but as one would expect, the bike in the end falls over when applying a steering force. In nature the centrifugal force has to be compensated mainly through leaning into the curve, so that the gravitational force compensates the centrifugal force. (I know this is only a simplification.)

Do you have any idea how to calculate the needed forces?

Thanks in advance! :)
StormChild
 
Posts: 3
Joined: Wed Apr 21, 2010 8:18 am
Location: Germany

Re: How to make a bicycle lean into a curve?

Postby Sash » Sat Apr 24, 2010 6:19 am

Just a pure suggestion:
I would start with first measuring this centrifugal force (by NewtonBodyGetForce, convert it local and then extract its side component).
Now when you know it you may implement side leaning - I think, by adding a (probably some coefficient will needed) torque to body in opposite direction.
Probably, instead of torque you will need to add a force at point above body's mass center.
Sash
 
Posts: 34
Joined: Wed Sep 30, 2009 3:38 am
Location: Novosibirsk

Re: How to make a bicycle lean into a curve?

Postby StormChild » Sun Apr 25, 2010 1:33 pm

First of all, thank you for your reply! :)

I think I am doing something completely wrong (I'm really not that good with math). My approach according to your idea was:

Code: Select all
   
//transform the global force in local space
Vector3 fo = body->getOgreNode()->getOrientation() * body->getForce();

//calculate a point 10 units above the center of mass   
Vector3 local_y_up = body->getCenterOfMass() + (body->getOgreNode()->getOrientation() * Vector3(0,1,0)).normalisedCopy() * 10;

//add the "counterforce"
body->addLocalForce( Vector3( - fo.x, 0, 0), local_y_up );


Are these calculations correct or did I mess something up with the math behind quaternions and rotations? If I apply this force (either only to the rear frame or to all four parts of the bike), it still falls down as if it did nothing. If I multiply a coefficient to the local force (say, two times fo.x) then the bike is going crazy, spinning round and flying (bouncing off the ground?) somewhere, the newton body shown by the debugger is then also apart from the real model.

Any help or hints are really appreciated! :)
StormChild
 
Posts: 3
Joined: Wed Apr 21, 2010 8:18 am
Location: Germany

Re: How to make a bicycle lean into a curve?

Postby Sash » Mon Apr 26, 2010 4:59 am

Sorry, it seems like you are using Ogre or Ogre-Newton wrapper. I never had a chance working with neither.
So I'm not sure what is body->getForce() - local or global vector (the same about Ogre's vector math operators).
I'm not at the position to give "guru" answers (I'm still new to Newton too), but here's my thoughts:

1.Use onscreen log to see what values you're gettng.
2. To get a local vector from global I'm using this approach: get body's matrix (either visual node or body), then inverse rotate (unrotate) global vector by this matrix.
But just check if OgreNewton returns global or local vector. Also see their API for applying force at some offset (there was some tutorial here too).
3. Value of 10.0 - seems to much for a force offset (if you're using metric units), and coefficient 2.0 for a leaning force is large too (I believe it should be less than 1.0).
4.Force should be applied to a hull body only, not for a forks or wheels (it's just simplier) - but it depends on mass distribution among your construction parts.

Again, use log, it will give you much more info than me :D
Sash
 
Posts: 34
Joined: Wed Sep 30, 2009 3:38 am
Location: Novosibirsk

Re: How to make a bicycle lean into a curve?

Postby StormChild » Wed Apr 28, 2010 8:26 am

Thank you for your reply! I'll try this out and hopefully get some better results than now. :)
StormChild
 
Posts: 3
Joined: Wed Apr 21, 2010 8:18 am
Location: Germany


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 3 guests