[ODE] Lot's of collisions crash ode

David Whittaker david at csworkbench.com
Tue Apr 22 15:14:02 2003


> Hi,
>
> I'm having a little problem. I'm new to ODE and I have created a little
> program to play around with. It consists of a world with one 'gravity'
> point.  When I click with my mouse the program inserts a cube into the
> world. This  cube is then pulled towards the gavity point. I do this by
> applying a force  towards the point. Also, I decrease the linear and
> angular speeds of all the  cubes in the world each step to simulate
> friction. Not a very good way I  guess but it works :)

This is generally done by adding a force in the direction of the velocity
times some negative scale factor.  Forces are more realistic and easier on
the solver, especially once you start adding other joints.

> If I insert some cubes in the world, let's say 15 cubes, they will all
> fly  around and bounce into each other. After a while they will settle
> around the  gravity point (because of the friction). Now the problem
> occurs. The cubes  will slowly slide into each other. This causes a lot
> of collisions. The  framerate will drop dramatically (from 300 fps to 2
> fps) and then it exists.  Without an error message.

Well, depending on your platform, you may or may not be able to fix this
as is.  In msvc, you can set the stack size for an executable... but I
forget where... maybe in the linker options under Project settings is it? 
Make it big.

But that will only fix the exiting problem, and not the slowness problem. 
However, there is a fix for that: the iterative stepfast algorithm.  You
can find that at http://www.csworkbench.com/stepfast.zip ... search the
archives for installation instructions (stick it in the main ode
directory, unzip, and recompile, then call
dWorldStepFast(world,stepsize,iterations) instead of
dWorldStep(world,stepsize)).  I promise, it's going in the CVS, along with
some documentation as to it's purpose and use, very soon.  At that point,
it will forever more be called: <drum roll> StepFast1!  I've run walls of
hundreds of cubes at >20 fps with it.

> I tried playing around with the collision parameters but nothing seems
> to fix  the problem. Does anyone have any ideas what may be causing
> this.

What's causing it?  ODE creates islands of bodies, i.e. when any two
bodies touch, they form an island.  For any given island, you can have a
rough idea of how long it will take to compute that island by counting up
the number of Degrees of Freedom (DOFs) removed by all the joints in the
island.  A frictionless contact removes 1 DOF, friction removes 3 DOFs.  A
face-face collision between two boxes generates 4 contact joints.  Ok, now
that you have that number, if you're not running the stepfast algorithm,
cube it, but if you are running the stepfast solver, just multiply it by
the number of iterations you passed in (usually 5-10).  The running time
of the biggest part of the solver is roughly proportional to this number. 
If you were to plot out a graph of DOF's removed vs running speed, you
could see that as islands get larger (i.e. stuff starts bumping into each
other), the stepfast algorithm remains calm (linear) compared to the
ballooning step algorithm.  However, what the stepfast algorithm gains in
speed, it loses in accuracy, so things like large mass ratios or big
forces tend to send it out of wack.  But if you're careful with your
initial mass setup (the best thing you can do is adjust every mass in the
simulation to 1.0, but I know that's not always possible), then those
large mass ratios and forces shouldn't come up.

David Whittaker

> Roel van Dijk
>
>
> _______________________________________________
> ODE mailing list
> ODE@q12.org
> http://q12.org/mailman/listinfo/ode