[ODE] Vehicle Speed (Generic Units to Real World Units)

Jeff Weber jeffreyweber at hotmail.com
Wed Jul 30 08:27:01 2003


Thanks for the insight Martin,

I am calling dWorldStep() with a constant .015.  Currently, I calculate how 
many .015 steps I need to match the time that has elapsed since last render. 
  Then I call WorldStep(.015) that many times.

Generally it's around 5-8 WorldSteps per render.

My loop looks something like follows.

RenderLoop()
{
DoPhysics()
Render World
}

DoPhysics()
{
  numberOfSteps = Time Elapsed Since Last Render/stepSize       
(stepSize=.015 currently)
  for(int i=1; i<=numberOfSteps;i++)
  {
   Check For Collisions

   WorldStep(.015)
  }
  Update positions and orientations of physics controlled objects
}

I put a cap on numberOfSteps.

After what you posted, I think I'll re-think my physics loop.  Any other 
hints / tips are welcome.

-j




----Original Message Follows----
From: "Martin C. Martin" <martin@metahuman.org>
To: Jeff Weber <jeffreyweber@hotmail.com>
CC: ode@q12.org
Subject: Re: [ODE] Vehicle Speed (Generic Units to Real World Units)
Date: Wed, 30 Jul 2003 10:08:27 -0400

Do this:

Before each call to dWorldStep(), remember the position of (the center of)
your wheel.  After the call, call dDISTANCE() on the previous & current
position.  That's the distance that the center of your wheel has moved.
Print that out.

Call getLinearVelociy() on your wheel, and multiply it by the time you
passed to dWorldStep().  Print it out.  The length of that vector should
be the same as above.  In fact, the vector should just be the difference
between the previous and current position, at least to a few significant
digits.

Call getAngularVelocity() on your wheel, take the component along the axis
of your wheel.  If the chassis isn't rotating, that should equal
getAngle2Rate().  Print both of them out and check that.

Multiply the value from the last paragraph by the time you passed to
dWorldStep(), and by the radius of your wheel.  In frames in which your
wheel doesn't slip, either side to side or "burn rubber," that should
equal the distance that the center of the wheel has traveled.

Are you sure your wheel isn't spinning against the ground?  Not sliding
side-to-side but burning rubber?  How do you know?

 > Our app does require that a 20 mile trip at 60 mph takes a real-world 
amount
 > of time.

You haven't answered my original question: are you ensuring that
dWorldStep() is called with the amount of real time that has passed?  If
you're calling it with a constant, say 0.01 sec for every frame that's
rendered, then the correspondence between simulated time and real time
will vary with frame rate.  Maybe this is why your numbers are off.

 > I think the piece i'm missing is the conversion factor between the 
arbitrary
 > time unit and seconds.

Measure (say using clock() or something higher resolution) the time
between consecutive calls to dWorldStep(), and compare it to the value
you're passing to dWorldStep().  That's the conversion factor you seek.

 > dBodyGetLinearVel returns a value of say 3.79 distance-units/time-unit.
 >
 > Or, using my conversion factor this equals .473 meters/time-unit
 >
 > Now, I mark off a distance of 100 meters in my 3d world and find that the
 > vehicle (at it's max speed) takes 26 seconds to go 100 meters. This means
 > that it was going 3.84 (100/26) meters/second.

Your 3.84 is close to your 3.79.  Are you sure you simply didn't forget a
conversion somewhere (or convert twice)?

 > I can then use this to determine that 1 arbitrary time unit = (.473/3.84)
 > seconds.

On your machine, for that particular frame, yes.

 > ----Original Message Follows----
 > From: "Martin C. Martin" <martin@metahuman.org>
 >
 > When you call dWorldStep(), do you call it with the number of wall clock
 > seconds that have passed, or otherwise try to keep simulation time the
 > same as wall clock time?

That question still stands.

- Martin
_______________________________________________
ODE mailing list
ODE@q12.org
http://q12.org/mailman/listinfo/ode

_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE*  
http://join.msn.com/?page=features/junkmail