[ODE] Torque instability

Russ Smith russ at q12.org
Fri Nov 23 15:27:01 MST 2001


> Earlier I wrote about instability after applying a torque to a
> floating body with no gravity or other forces. I forgot to mention
> that I apply exactly ONE torque for ONE timestep, and apply NO torque
> or forces thereafter. Still, after several timesteps, the system
> becomes instable, the box spins faster and faster, then eventually
> flies off into "nan" land.
> 
> Any ideas why?

yes. this is a common problem. here is the explanation:

ODE uses a first order semi-implicit integrator. the "semi implicit"
means that some forces are calculated as though an implicit integrator
is being used, and other forces are calculated as though the
integrator is explicit. the constraint forces (applied to bodies to
keep the constraints together) are implicit, and the "external" forces
(applied by the user, and due to rotational effects) are explicit.
now, inaccuracy in implicit integrators is manifested as reduction in
energy - in other words the integrator damps the system for you.
inaccuracy in explicit integrators has the opposite effect - it
increases the system energy. this is why systems simulated with
explicit euler (first order) integrators can "explode".

so, a single body tumbling in space is effectively explicitly
integrated. if the body's moments of inertia were equal (such as a
sphere) then the rotation axis would remain constant, and the
integrator error would be small. if the body's moments of inertia
are unequal then the rotation axis wobbles as momentum is transferred
between different rotation directions. this is the correct physical
behavior, but it results in higher integrator error. because the
integrator in this case is explicit, the error increases the energy,
which causes faster and faster rotation, causing more and more error -
leading to the explosion.

the problem is particularly evident with long thin objects, where the
3 moments of inertia are highly unequal. for example, a long thin box
dropped on a bouncy floor just right will start quickly spinning along
its long axis, and this motion transfers to other directions - and an
explosion occurrs. the test_boxstack demo was recently modified to use
correct inertias for the objects - the result is that some box objects
are less stable.

to prevent this, do one or more of the following:
  * make sure freely rotating bodies are dynamically symmetric (i.e.
    all moments of inertia are the same, the inertia matrix is a
    constant times the identity matrix). note that you can still
    render and collide with a long thin box even though it has the
    inertia of a sphere.
  * make sure freely rotating bodies dont spin too fast (e.g. don't
    apply large torques, or supply damping forces).
  * add extra damping elements to the environment, e.g. don't use
    bouncy collisions that can reflect energy.
  * use smaller timesteps. this is bad for two reasons: it's slower,
    and ODE is first order so the added accuracy is minimal.
  * use a higher order integrator. this is not yet an option in ODE.

another solution is to modify the rotational dynamics so that there is
no error with an explicit first order integrator. i think that this
may have been added to CML's vortex library (not sure). this feature
could be added to ODE at some point.

i think i'll add this to the ODE faq.

russ.

--
Russell Smith
http://www.q12.org



More information about the ODE mailing list