[ODE] problems with vectors, I think

Martin C. Martin martin at metahuman.org
Mon Dec 8 13:39:46 MST 2003


If nobody replies to your post, that means they can't help you.

It might help if you track the problem down a little more.  The fact 
that you have the entire source is a big help here.  Find out what 
exactly is causing these messages, my guess is, well, some dMass 
structure has a mass <= 0 and either that same dMass or a different one 
has a messed up inertia tensor.  Find out which ones, then set a 
breakpoint when the values change.  Where does the non-positive mass 
come from?  Is the dMass not being initialized?  Does it get 
accidentally freed and overwritten?  Does it get overwritten because 
some other array somewhere goes over bounds?  The possibilities are 
endless, but aren't too hard to track down with a little investigation.

Cheers,
Martin


John Sparks wrote:
> I am trying to run the code posted on 6/1/2003 by Shaul Kedem.  I 
> originally had it working but now I get errors.
>  
> "mass must be > 0" from mass.cpp
> "inertia must be positive definite" from ode.cpp
>  
> I'm using ODE 0.035 and have included the code below.  Any ideas as to 
> why it is doing this?
>  
> Thanks,
> John
>  
> #include "ode/ode.h"
> 
> dWorldID aWorld ;
> dBodyID aBody;
> dSpaceID aSpace;
> dGeomID aSphere;
> dGeomID aGround;
> dJointGroupID grpContacts;
> 
> static void nearCallback (void *data, dGeomID o1,
> dGeomID o2)
> {
>   int i;
> 
>   dBodyID b1 = dGeomGetBody(o1);
>   dBodyID b2 = dGeomGetBody(o2);
>   if (b1 && b2 && dAreConnectedExcluding
> (b1,b2,dJointTypeContact))
>   {
>   return;
>   }
> 
>   dContact contact[4]; // up to 4 contacts per box-box
>   for (i=0; i<4; i++) {
>     contact[i].surface.mode = dContactBounce |
> dContactSoftCFM |dContactSoftERP;
>     contact[i].surface.mu = dInfinity;
>     contact[i].surface.mu2 = 0;
>     contact[i].surface.bounce = 0.1;
>     contact[i].surface.bounce_vel = 0.1;
>     contact[i].surface.soft_cfm = 0.001;
> contact[i].surface.soft_erp = 1.0;
>   }
>   int numc = dCollide
> (o1,o2,4,&contact[0].geom,sizeof(dContact));
>   if (numc) {
> 
> dMatrix3 RI;
>     dRSetIdentity (RI);
>     const dReal ss[3] = {1.0,1.0,1.0};
>     for (i=0; i<numc; i++) {
> dJointID c = dJointCreateContact
> (aWorld,grpContacts,&contact[i]);
>       dJointAttach (c,b1,b2);
>     }
>   }
> }
> 
> 
> void main ( void )
> {
> int count = 0;
> aWorld = dWorldCreate();
> dWorldSetGravity (aWorld,0,0,-0.5);
>     dWorldSetCFM (aWorld,1e-5);
> aSpace = dHashSpaceCreate (0);
> dMass m;
> aBody = dBodyCreate (aWorld);
> dBodySetPosition ( aBody,0,0,10 );
> dMassSetSphere  (&m,0.2,1.0f );
> aSphere = dCreateSphere ( aSpace, 1.0f );
> dBodySetMass ( aBody,&m );
> dGeomSetBody ( aSphere,aBody );
> aGround = dCreatePlane ( aSpace,0,0,1,0 );
> grpContacts = dJointGroupCreate (0);
> dReal *pos;
> 
> do
> {
> dJointGroupEmpty (grpContacts);
> dSpaceCollide (aSpace,0,&nearCallback);
> dWorldStep (aWorld, 0.1);
> pos = (dReal *)dGeomGetPosition(aSphere);
> printf ( "%f,%f,%f\n",pos[0],pos[1],pos[2] );
> 
> // use this sleep to see what happens, you can safely remove it
> _sleep(10);
> 
> if ( pos[2] < 1.0 )
> count ++;
> 
> // to get the rotation use
> dGeomGetRotation(aSphere);
> } while ( count < 20 ) ;
> 
> dJointGroupDestroy (grpContacts);
> dSpaceDestroy(aSpace);
> dWorldDestroy (aWorld);
> dCloseODE();
> }
> 
>     ----- Original Message -----
>     From: John Sparks <mailto:pnk4jss at ufl.edu>
>     To: ode at q12.org <mailto:ode at q12.org>
>     Sent: Friday, December 05, 2003 3:52 AM
>     Subject: mass/inertia problems?
> 
>     I am trying to run the code posted on 6/1/2003 by Shaul Kedem.  I
>     originally had it working but now I get errors.
>      
>     "mass must be > 0" from mass.cpp
>     "inertia must be positive definite" from ode.cpp
>      
>     I'm using versioni 0.035 and have included the code below.  Any
>     ideas as to why it is doing this?
>      
>     Thanks,
>     John
>      
>     #include "ode/ode.h"
> 
>     dWorldID aWorld ;
>     dBodyID aBody;
>     dSpaceID aSpace;
>     dGeomID aSphere;
>     dGeomID aGround;
>     dJointGroupID grpContacts;
> 
>     static void nearCallback (void *data, dGeomID o1,
>     dGeomID o2)
>     {
>       int i;
> 
>       dBodyID b1 = dGeomGetBody(o1);
>       dBodyID b2 = dGeomGetBody(o2);
>       if (b1 && b2 && dAreConnectedExcluding
>     (b1,b2,dJointTypeContact))
>       {
>       return;
>       }
> 
>       dContact contact[4]; // up to 4 contacts per box-box
>       for (i=0; i<4; i++) {
>         contact[i].surface.mode = dContactBounce |
>     dContactSoftCFM |dContactSoftERP;
>         contact[i].surface.mu = dInfinity;
>         contact[i].surface.mu2 = 0;
>         contact[i].surface.bounce = 0.1;
>         contact[i].surface.bounce_vel = 0.1;
>         contact[i].surface.soft_cfm = 0.001;
>     contact[i].surface.soft_erp = 1.0;
>       }
>       int numc = dCollide
>     (o1,o2,4,&contact[0].geom,sizeof(dContact));
>       if (numc) {
> 
>     dMatrix3 RI;
>         dRSetIdentity (RI);
>         const dReal ss[3] = {1.0,1.0,1.0};
>         for (i=0; i<numc; i++) {
>     dJointID c = dJointCreateContact
>     (aWorld,grpContacts,&contact[i]);
>           dJointAttach (c,b1,b2);
>         }
>       }
>     }
> 
> 
>     void main ( void )
>     {
>     int count = 0;
>     aWorld = dWorldCreate();
>     dWorldSetGravity (aWorld,0,0,-0.5);
>         dWorldSetCFM (aWorld,1e-5);
>     aSpace = dHashSpaceCreate (0);
>     dMass m;
>     aBody = dBodyCreate (aWorld);
>     dBodySetPosition ( aBody,0,0,10 );
>     dMassSetSphere  (&m,0.2,1.0f );
>     aSphere = dCreateSphere ( aSpace, 1.0f );
>     dBodySetMass ( aBody,&m );
>     dGeomSetBody ( aSphere,aBody );
>     aGround = dCreatePlane ( aSpace,0,0,1,0 );
>     grpContacts = dJointGroupCreate (0);
>     dReal *pos;
> 
>     do
>     {
>     dJointGroupEmpty (grpContacts);
>     dSpaceCollide (aSpace,0,&nearCallback);
>     dWorldStep (aWorld, 0.1);
>     pos = (dReal *)dGeomGetPosition(aSphere);
>     printf ( "%f,%f,%f\n",pos[0],pos[1],pos[2] );
> 
>     // use this sleep to see what happens, you can safely remove it
>     _sleep(10);
> 
>     if ( pos[2] < 1.0 )
>     count ++;
> 
>     // to get the rotation use
>     dGeomGetRotation(aSphere);
>     } while ( count < 20 ) ;
> 
>     dJointGroupDestroy (grpContacts);
>     dSpaceDestroy(aSpace);
>     dWorldDestroy (aWorld);
>     dCloseODE();
>     }
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> ODE mailing list
> ODE at q12.org
> http://q12.org/mailman/listinfo/ode



More information about the ODE mailing list