[ODE] bouncy car

Luke Kenneth Casson Leighton lkcl at lkcl.net
Sun Nov 7 14:24:56 MST 2004


hi, just for fun i figured i'd try doing a car with that funny
race-style suspension, you know, like a sand buggy.

well, it kinda works.

having been playing about, therefore, i have a couple of questions and a
couple of suggestions:

1) the design of the ode library critically depends on OpenGL.

   good library design dictates that you pass in a set of pointers to
   functions that _your_ library calls in order to do what it wants to
   do.

   in the case of libode, that would mean making setCamera, setColor,
   setTransform, drawBox etc. all part of an "external" OpenGL-specific
   library which libode would use.

2) i was surprised to find that hinges do not have a means for
   developers to apply forces or torques "via" the hinge.

   what i mean by that is that in order to implement a spring,
   the developer must MANUALLY calculate the direction of the forces
   on the objects.

   i would have expected to be able to say "on this joint, apply a force
   in both directions along the axis, onto the two bodies it connects,
   at the connecting points".

   in this way, the calculations are all performed "behind the scenes".
   
   surely, you know where the axis joins the two bodies, and if that
   isn't known then i would imagine it to be a relatively
   straightforward task to add "contact" points on the two bodies at
   which the forces could be applied.

i found that i had to "fudge" the sand buggy suspension by applying
forces to the middle of the wheel and to the middle of one of the
suspension struts (between the crosses):
 

----x----  body
| /
x
|
----x----  body

questions:

1) does anyone know of any good open source "landscape" creating code?
   blank space is really boring and deceptive.

   i really liked the look of that landscape that i saw someone created
   who was modelling an automated rover before building it.

   [btw i hope your rover's suspension can lift up and down to avoid
    obstacles!]

   i've also played with bzflag, but don't really fancy merging two sets
   of disparate code together (yet).


2) can someone advise me what functions i should call to work out a
vector pointing up at right angles to a surface on the "car"?

 i realise this is probably a very simple question - one that i won't
 need to ask more than once.

 i need to apply a speed-related downforce onto the car of course but
 i am presently applying it in the z-direction only.

 what i want to do is apply wind-related forces on every surface.

 as follows:

 foreach surface sf of area sz:

	 dReal *velocity = dBodyGetLinearVel(car);
	 dReal *pos = dBodyGetPosition(car);

	// gives me a vector pointing in the absolute direction of
	// each vehicle's surface.  so if the vehicle is pointing
	// (1, 0, 0) then the "rear" surface points (-1, 0, 0)
	// and the "left" surface points (0, -1, 0).
	 dReal *surfvector = somehowmultiply(pos, sf);

	dReal velocitysqd[3];
	velocitysqd[0] = velocity[0]*velocity[0];
	... 1 1 1;
	... 2 2 2;

    // gives me a scalar telling me how much wind-force to apply
	 dotproduct = dotproductfunction(velocitysqd, surfvector);

	 dBodyApplyForce(sz * dotproduct * resistance, surfvector[0], [1], [2]);


 of course, if i put "spoilers" on the car, the surfaces will point
 (0.707, 0, -0.707) or thereabouts.

 which will result in downforce _and_ drag being applied as the vehicle
 accelerates.

 it also means that if the vehicle gets airborne and starts to tumble,
 the vehicle will present belly to the "wind" and go off in some wild
 but scarily realistic direction like you see in F1 or indycar
 spectacular crashes.

 some assistance in filling in the blanks "somehowmultiply" and
 "dotproductfunction" above greatly appreciated.

 l.


-- 
--
you don't have to BE MAD   | this space    | my brother wanted to join mensa,
  to work, but   IT HELPS  |   for rent    | for an ego trip - and get kicked 
 you feel better!  I AM    | can pay cash  | out for a even bigger one.
--


More information about the ODE mailing list