[ODE] dWorldSetAutoDisableFlag doesn't work?

Mohsin Hasan mohsin.hasan at trivor.com
Tue May 25 11:39:16 MST 2004


No. I'm not using test_crash.cpp. I've written my stacking app from scratch.

There is definitely discrepancy between how the defaults are set in ODE (in
dBodyCreate) and how the parameters are set for individual objects.

I've traced it. Here is what's causing the problem. In file ode.cpp and
function dBodyCreate(***)
.
.
.
  // set auto-disable parameters
  dBodySetAutoDisableDefaults (b);	// must do this after adding to
world
  b->adis_stepsleft = b->adis.idle_steps;
  b->adis_timeleft = b->adis.idle_time;

Notice after setting the dBodyAutoDisableDefaults, adis_stepsleft and
adis_timeleft are set with the default parameters (the ones that world has).

Now if I manually set these parameters using

dBodySetAutoDisableLinearThreshold
dBodySetAutoDisableAngularThreshold

They set the adis.idle_steps variable only and ignore adis_stepsleft
variable. Similarly for the timeleft variable. ODE is decrementing these
variables in each time step and resetting them once they are < 0.

Assuming I don't set any values for dWorldSetAutoDisable* and set these
values for individual objects only. Now for the first iteration
adis_stepsleft will have the default value (10... set by ODE) because it was
only set at body creation time. Once it gets < 0 only then it will be reset
to 50 (the value I actually want).

I also noticed discrepancies in how the linear and angular thresholds are
set for defaults and individual objects. If they are set for each body
individually (using dBodySetAutoDisableLinearThreshold) they are set as the
square of the value we set. But if they are set from world (in dBodyCreate),
they are set as the actual value that we set (using
dWorldGetAutoDisableLinearThreshold (w) which returns the square root of the
stored value). Why is that?

Mohsin





-----Original Message-----
From: Nguyen Binh [mailto:ngbinh at glassegg.com] 
Sent: Tuesday, May 25, 2004 9:06 AM
To: Mohsin Hasan
Cc: ode at q12.org
Subject: Re: [ODE] dWorldSetAutoDisableFlag doesn't work?

Hi Mohsin,

MH> According to documentation dWorldSetAutoDisableFlag and all the other
MH> dWorldSetAutoDisable* functions set the defaults for any object created
in
MH> the world. Apparently it means if I set the parameters for world, I
don't
MH> have to individually set these parameters for each body. But it doesn't
seem
MH> to work for me. As long as I specify these parameters for individual
bodies
MH> only (and not for world) it works. But if I set the world parameters it
MH> doesn't work anymore even if I set the same parameters for individual
bodies
MH> afterwards. Apparently creating a body gets the default parameters from
the
MH> world but sets them in some other variables whereas setting these
parameters
MH> to the body directly sets bit flags to another parameter. Has anyone
else
MH> experienced it? I would have traced it more but it's pretty late and I'm
MH> tired. Or am I understanding the feature wrong? 

    I'd bet you are using test_crash.cpp. The problem is
    test_crash.cpp is older than "official" AutoDisable stuff.
    Look at the code :
----------------
                else
                {
                        dSpaceCollide (space,0,&nearCallback);
                        dWorldStep (world,0.05);
                        dJointGroupEmpty (contactgroup);
                }
                
                for (i = 0; i < wb; i++)
                {
                        b = dGeomGetBody(wall_boxes[i]);
                        if (dBodyIsEnabled(b)) 
                        {
                                bool disable = true;
                                const dReal *lvel = dBodyGetLinearVel(b);
                                dReal lspeed =
lvel[0]*lvel[0]+lvel[1]*lvel[1]+lvel[2]*lvel[2];
                                if (lspeed > DISABLE_THRESHOLD)
                                        disable = false;
                                const dReal *avel = dBodyGetAngularVel(b);
                                dReal aspeed =
avel[0]*avel[0]+avel[1]*avel[1]+avel[2]*avel[2];
                                if (aspeed > DISABLE_THRESHOLD)
                                        disable = false;
                                
                                if (disable)
                                        wb_stepsdis[i]++;
                                else
                                        wb_stepsdis[i] = 0;
                                
                                if (wb_stepsdis[i] > DISABLE_STEPS)
                                {
                                        dBodyDisable(b);
                                        dsSetColor(0.5,0.5,1);
                                }
                                else
                                        dsSetColor(1,1,1);

                        }
                        else
                                dsSetColor(0.4,0.4,0.4);
                        dVector3 ss;
                        dGeomBoxGetLengths (wall_boxes[i], ss);
                        dsDrawBox(dGeomGetPosition(wall_boxes[i]),
dGeomGetRotation(wall_boxes[i]), ss);
                }
        }
----------------

You'll see that David (the original author of test_crash.cpp) had
tried to do auto disable his own.

Just comment out those lines and you'll see "official" ODE code comes
out.

-- 
Best regards,

---------------------------------------------------------------------
   Nguyen Binh
   Software Engineer
   Glass Egg Digital Media
   
   E.Town Building  
   7th Floor, 364 CongHoa Street
   Tan Binh District,
   HoChiMinh City,
   VietNam,

   Phone : +84 8 8109018
   Fax   : +84 8 8109013

     www.glassegg.com
---------------------------------------------------------------------





More information about the ODE mailing list