[ODE] Worst Case Scenario - State save and restore

Alex Green alexg at acfr.usyd.edu.au
Tue Feb 8 14:57:29 MST 2005

I definitely agree with that! I am trying to do the same thing at the 
moment and my approach is below.
Is anyone happy to share there code for state save/restore and for 
encapsulation of model making? I will be happy to share what I have done 
so far or the lot when I get it finished.

My solution to both:
Each time I create a body I create an object and fill out the initial 
details such as size, weight, object type, geom type size, etc. No ODE 
body is created as yet.

I then call a createBody() fn in that object. This calls dBodyCreate(), 
dMassSetBox() (assuming a box), etc to initialise the body and geom.

My object stores all the initial values as well as all the pointers to 
the IDs, keeping it all in one place. It also has a second set of 
variables for state: position, quaternion, linearVel and angularVel.
These are saved with a saveState() fn. And (I hope) they can be restored 
with a setState() fn.

For the jointObject the same thing. All the initial values are stored 
AND a state consisting of (use a hinge as an example):
dJointGetHingeAnchor (dJointID, dVector3 result);
dJointGetHingeAnchor2 (dJointID, dVector3 result);
dJointGetHingeAxis (dJointID, dVector3 result);
dJointGetHingeAngle (dJointID);
dJointGetHingeAngleRate (dJointID);

The hope is that the state will restore fine with this. If the joints 
don't match up on the bodies ok, I can recreate the bodies and joints 
from initial values and then update the state.

One final thing, what happens if you point the following two functions 
to user space and then save the contents?:
void dJointSetData (dJointID, void *data);
void  dBodySetData (dBodyID, void *data);

Cheers -alex
PhD student, University of Sydney

Graham Fyffe wrote:
> Seems to me one thing ODE is sorely missing is a dBodySaveState(some
> struct pointer) and dBodyRestoreState(some struct pointer).
> - Graham Fyffe

More information about the ODE mailing list