[ODE] AMD x86_64 dMassCheck() and bNormalizationResult errors
Funky Fred
funkyfredmale at hotmail.com
Sun Nov 18 01:08:02 MST 2007
Hello,
using code that worked on x86_32,
dMass dmass;
dMassSetZero( &dmass );
//dMassAdjust( &dmass, mass );
dmass.mass = mass;
dBodySetMass( bodies[name], &dmass );
return true;
gives me (on x86_64 - AMD):
(more code further down)
Starting program: /home/stu/evolve/physicsEngine/testPhysicsEngine
[Thread debugging using libthread_db enabled]
[New Thread 47826867859296 (LWP 8997)]
gravity: 0,10,0
ODE Message 2: inertia must be positive definite in dMassCheck() File mass.cpp Line 48
ODE INTERNAL ERROR 1: assertion "dMassCheck(mass)" failed in dBodySetMass() [ode.cpp]
Program received signal SIGABRT, Aborted.
[Switching to Thread 47826867859296 (LWP 8997)]
0x00002b7f8f23d765 in raise () from /lib/libc.so.6
(gdb) bt
#0 0x00002b7f8f23d765 in raise () from /lib/libc.so.6
#1 0x00002b7f8f23f1c0 in abort () from /lib/libc.so.6
#2 0x00002b7f8e7a38f6 in dDebug (num=,
msg=) at error.cpp:102
#3 0x00002b7f8e7a1ec9 in dBodySetMass (b=0x60e450, mass=0x7fff1c548680)
at ode.cpp:472
#4 0x000000000040614f in evolve::PhysicsEngine::setMass (
this=, name=@0x7fff1c548930, mass=10)
at PhysicsEngine.cc:174
#5 0x00000000004095d3 in main () at testPhysicsEngine.cc:25
(gdb)
If I change to
dMass dmass;
dMassSetZero( &dmass );
dMassAdjust( &dmass, mass );
//dmass.mass = mass;
dBodySetMass( bodies[name], &dmass );
return true;
gravity: 0,10,0
before:
pos 1: 0,10,0
pos 2: 0,10,0
ODE INTERNAL ERROR 1: assertion "bNormalizationResult" failed in _dNormalize4() [../../include/ode/odemath.h]
Program received signal SIGABRT, Aborted.
[Switching to Thread 47280432254816 (LWP 8903)]
0x00002b00550a3765 in raise () from /lib/libc.so.6
(gdb) bt
#0 0x00002b00550a3765 in raise () from /lib/libc.so.6
#1 0x00002b00550a51c0 in abort () from /lib/libc.so.6
#2 0x00002b00546098f6 in dDebug (num=,
msg=) at error.cpp:102
#3 0x00002b005464283a in dxStepBody (b=0x60e680, h=4.59163468e-41)
at ../../include/ode/odemath.h:304
#4 0x00002b0054610a6f in dxQuickStepper (world=0x60e010, body=0x7fff566e2830,
nb=2, _joint=, nj=1, stepsize=1) at quickstep.cpp:868
#5 0x00002b00546422cd in dxProcessIslands (world=0x60e010, stepsize=1,
stepper=0x2b005460f630 ) at util.cpp:339
#6 0x00000000004042fe in evolve::PhysicsEngine::doPhysics (
this=0x7fff566e2920) at PhysicsEngine.cc:240
#7 0x0000000000409920 in main () at testPhysicsEngine.cc:37
I'm using a test program that calls a C++ wrapper class. Relevant snippets are:
testPhysicsEngine.cc
...
PhysicsEngine pe;
vector grav = Utility::makeVector( 0.0, 10.0, 0.0 );
pe.setGravity( grav[0], grav[1], grav[2] );
grav.clear();
pe.getGravity( grav );
cout << "gravity: " << Utility::vectorToString( grav ) << endl;
vector pos = Utility::makeVector( 0.0, 10.0, 0.0 );
vector pos2 = Utility::makeVector( 0.0, 10.0, 0.0 );
vector newpos1;
vector newpos2;
pe.addItem( "test1", pos, 5 );
pe.addItem( "test2", pos2, 2 );
pe.setMass( "test1", 10.0 );
pe.setMass( "test2", 5.1 );
cout << "before: " << endl;
pe.getPosition( "test1", newpos1 );
pe.getPosition( "test2", newpos2 );
cout << "pos 1: " << Utility::vectorToString( newpos1 ) << endl;
cout << "pos 2: " << Utility::vectorToString( newpos2 ) << endl;
vector vel = Utility::makeVector( 0.0, -3.0, 0.0 );
pe.setLinearVelocity( "test2", vel );
for( int i = 0; i < 5; ++i )
pe.doPhysics();
...
PhysicsEngine.cc
...
PhysicsEngine::PhysicsEngine()
{
this->worldId = dWorldCreate();
this->spaceId = dHashSpaceCreate( 0 );
this->contactJointGroup = dJointGroupCreate( 0 );
dWorldSetGravity( this->worldId, 0, 0, 0 );
}
bool PhysicsEngine::addItem( const string& name, const vector& pos, double radius )
{
...
dGeomID geometry = dCreateSphere( this->spaceId, radius );
dBodyID body = dBodyCreate(this->worldId);
dGeomSetBody( geometry, body );
dBodySetPosition( body, pos[0], pos[1], pos[2] );
bodies[name] = body;
return true;
}
bool PhysicsEngine::setMass( const string& name, double mass )
{
...
dMass dmass;
dMassSetZero( &dmass );
//dMassAdjust( &dmass, mass );
dmass.mass = mass;
dBodySetMass( bodies[name], &dmass );
return true;
}
bool PhysicsEngine::doPhysics()
{
dSpaceCollide( this->spaceId, this, &nearCollisionCallback );
dWorldQuickStep( this->worldId, 1 );
dJointGroupEmpty( this->contactJointGroup );
return true;
}
/*
* callback for ODE. friend of PhysicsEngine. _this is meant to be
* a this pointer at the PhysicsEngine object currently using the callback.
*/
void evolve::nearCollisionCallback( void* _this, dGeomID id1, dGeomID id2 )
{
dBodyID b1 = dGeomGetBody( id1 );
dBodyID b2 = dGeomGetBody( id2 );
//if( b1 && b2 && dAreConnectedExcluding( b1, b2, dJointTypeContact ) )
// return;
short max_contacts = 10;
dContact contacts[10]; //delete ?
for( int i = 0; i < 10; ++i )
{
contacts[i].surface.mode = dContactBounce | dContactSoftCFM;
contacts[i].surface.mu = dInfinity;
contacts[i].surface.mu2 = 0;
contacts[i].surface.bounce = 0.8;
contacts[i].surface.bounce_vel = 0.1f;
contacts[i].surface.soft_cfm = 0.01f;
}
int num_contacts = 0;
num_contacts = dCollide( id1, id2, (unsigned int)max_contacts, &contacts[0].geom, sizeof(dContact) );
for( int i = 0; i < num_contacts; ++i )
{
dJointID c = dJointCreateContact( ((PhysicsEngine*)_this)->worldId, ((PhysicsEngine*)_this)->contactJointGroup, &contacts[i] );
dJointAttach( c, b1, b2 );
}
}
Hope this all makes sense, any help would be appreciated. I tried digging into the ODE source files, but didn't make much progress. I gotta sleep now.
cheers,
-Stu
_________________________________________________________________
Share life as it happens with the new Windows Live.Download today it's FREE!
http://www.windowslive.com/share.html?ocid=TXT_TAGLM_Wave2_sharelife_112007
More information about the ODE
mailing list