#8 ODEDynamics improvements

closed-accepted
nobody
None
5
2010-05-03
2010-04-08
Alex
No

This patch contains the following ODEDynamics improvements:

1) Method for removing objects from ODE simulation (they are still
rendered, but they don't interact any more with other bodies)

2) Quick access to a body manipulator using the 'manip' field.
After adding a body to ODEDynamics, it receives a new field, 'manip'.
Therefore, it is much easier to manipulate objects.

Example:
s = Sphere()
odeSim = ODEDynamics()
odeSim.add(s)

# now 's' has a 'manip' field:

s.manip.setPos((1,1,0))
s.manip.addForce((0,0,1))

A small inconvenience is that every object present in the simulation
also has a corresponding ODEBodyManipulator allocated. This can be
optimized by implementing 'manip' as a property and create the
ODEBodyManipulator only when user code actually tries to use the
'manip' field.

However, I did some profiling and did not notice any decrease in
performance. My simulation had 10-20 boxes and 5 trimeshes.

3) Access to ODE geoms using the 'odegeoms' property in ODEBodyManipulator.
Before, I wanted to change the collide bits during simulation, and this
wasn't easy since the ODE geoms were hidden.

4) Use default mass = 1 for objects without mass set
(Before, adding an object without mass to the simulation resulted
in ODE crash)

5) Collision events between a pair of bodies with materials (mat1,mat2)
and contact properties set always occurs in the same order (1,2)

Benefits:
* contact normal is always in the same direction (deterministic)
* Fdir1 is always in the same direction => it is possible to simulate
a conveyor belt.

Before, the order in which the two bodies appeared in the collision
event was undefined, resulting in Fdir1 always changing its sign
randomly (and also the direction of the conveyor belt).

6) ODEBodyManipulator automatically wakes up (enables) the associate body
when using setPos, setRot, setLinearVel, setAngularVel, addForce or
addTorque.

Before, if one used AutoDisable flag for performance reasons, a call
to e.g. addForce did not move a stationary body, because it was
automatically disabled by ODE.

Now, the body wakes up automatically upon manipulation.

7) fixed ODEBodyManipulator.setRot
(it didn't accept a mat3 argument, since PyODE wanted a list).
Now it can also accept a list in row-major order.

8) Added ODEFixedJoint class.
It is useful for modeling complex rigid bodies with different contact
properties on different sides.

I have used this to simulate a pen which can draw on paper with its tip,
and also can be manipulated (grasped) from its body. Therefore, the pen
is made of two "glued" objects: one which has friction and can be
grasped (the pen body), and other (the ballpoint tip) which has mu=0
between itself and Paper object.

9) Documented the above changes, added some of my observations on the
way ODEDynamics works, and also added some links to the new ODE wiki.

Regards,
Alex

Discussion

  • Alex

    Alex - 2010-04-08

    ODEDynamics improvements

     
  • Matthias Baas

    Matthias Baas - 2010-05-03
    • status: open --> closed-accepted
     
  • Matthias Baas

    Matthias Baas - 2010-05-03

    Sorry for the delay, I finally applied and pushed this patch. Thanks!
    Thanks for the docs update. There's just one thing: when you add or modify methods, make sure the doc strings are still in sync. The remove() method still had the doc string from the add() method. :)
    I also did some minor reformatting on the rst docs.

    By the way, I can't see your full name anywhere here to give you credits in the changelog. So if you want to be mentioned there, mail me what I should put into the file. :)

     
  • Alex

    Alex - 2010-05-04

    Thanks! I have also noticed the docstring from add(), but too late :)

    A suggestion (maybe for cgkit alpha 10):
    The PyPi version of cgkit is rather old, you should consider updating it. It would be nice for the users to install it with just a single command (sudo easy_install cgkit).

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks