[ODE] ODE Message 3: LCP internal error (with code example)
aldoric@gmx.de
aldoric at gmx.de
Tue Aug 15 04:17:29 MST 2006
Hi!
(Hope this message didn't receive three times. >.>)
I'm getting the following error message while simulating:
ODE Message 3: LCP internal error, s <= 0 (s=0.0000e+00)
Can someone explain me how to fix this?
Here is my main cpp file (handles ALL ODE functions, yet (Temporary to test)): (Is made a bit shorter)
======================================================================
// ...
#define BALL_RADIUS 2.0f
// TEMPORARY
dWorldID world;
dGeomID plane, ball, ball2, box;
dBodyID ballBody, boxBody, boxBody2;
dJointGroupID jgroup, contactjoints;
//----------------------------------------------------------------
// Scene for testuses
//----------------------------------------------------------------
class CTestScene : public CScene
{
public:
//--------------------------------------------
void ResetSimulation( void )
{
printf("CTestScene::ResetSimulation( );\n");
// Set ball position
dBodySetPosition ( ballBody, 1, 30, 2 );
dBodySetLinearVel ( ballBody, 0, 0, 0 );
dBodySetAngularVel( ballBody, 0, 0, 0 );
// Set box position
dBodySetPosition( boxBody, 20, 8, 30 );
dBodySetLinearVel ( boxBody, 0, 0, 0 );
dBodySetAngularVel( boxBody, 0, 0, 0 );
// Reset Scale sum
fScaleSum = 0.0f;
}
//--------------------------------------------
void SceneInit( CEngine *pEngine, void *pParameter )
{
// ...
// Setup ODE
printf("\033[1m<Setup ODE>\033[0m\n");
// Create WORLD
world = dWorldCreate( );
dWorldSetGravity (world,0,-0.05f,0);
// #### SPACE solution is coming soon ####
// Create geoms / bodies
plane = dCreatePlane (0, 0,1,0,0);
ball = dCreateSphere(0, BALL_RADIUS);
ball2 = dCreateSphere(0, BALL_RADIUS*5);
box = dCreateBox (0, 8, 8, 8 );
ballBody = dBodyCreate( world );
boxBody = dBodyCreate( world );
boxBody2 = dBodyCreate( world );
dGeomSetBody( ball, ballBody );
dGeomSetBody( box, boxBody );
// Set mass
dMass mass, mass2;
dMassSetSphere( &mass, 1, BALL_RADIUS);
dBodySetMass( ballBody, &mass );
dMassSetBox( &mass2, 0.01, 8, 8, 8 );
dBodySetMass( boxBody, &mass2 );
// Set positions
dGeomSetPosition( ball2, 1, 5, 0 );
ResetSimulation( );
jgroup = contactjoints = dJointGroupCreate(0);
printf("\033[1m</Setup>\033[0m\n");
// ...
}
//--------------------------------------------
void SceneFree( void )
{
// ...
printf( "\033[1m<Free ODE />\033[0m\n" );
dJointGroupEmpty(jgroup);
dWorldDestroy( world );
dCloseODE ( );
printf( "CTestScene::SceneFree( );\n" );
}
//--------------------------------------------
// ...
//--------------------------------------------
float fScaleSum; // TEMPORARY
void FrameMove( float fScale )
{
// ...
// Move sphere
if ( m_keyYAxis.cState<0 ) dBodyAddForce( ballBody, 0, 0, -3*fScale );
else if ( m_keyYAxis.cState>0 ) dBodyAddForce( ballBody, 0, 0, 3*fScale );
if ( m_keyXAxis.cState<0 ) dBodyAddForce( ballBody, -3*fScale, 0, 0 );
else if ( m_keyXAxis.cState>0 ) dBodyAddForce( ballBody, 3*fScale, 0, 0 );
// World steps always in 0.3 steps, because the simulation is running different
// if I don't use the function this way
fScaleSum += fScale;
while ( fScaleSum>0.3f )
{
dWorldStep( world, 0.3f );
fScaleSum -= 0.3f;
}
//-- TEMPORARY COLLISION --
const int NUM_CONTACTS = 3;
dContact contacts[NUM_CONTACTS];
int numCollisions, i;
/* COLLISION - will be replaced by dSpaceCollide soon to prevent thousands of code blocks */
numCollisions = dCollide(ball, plane, NUM_CONTACTS, &contacts[0].geom, sizeof(dContact));
dJointGroupEmpty(jgroup);
for(i = 0; i < numCollisions; ++i)
{
contacts[i].surface.mode = dContactBounce | dContactApprox1;
contacts[i].surface.mu = 250;
contacts[i].surface.bounce = 0.6;
contacts[i].surface.bounce_vel = 0.15;
dJointID c = dJointCreateContact(world, jgroup, &contacts[i]);
dJointAttach(c, dGeomGetBody(contacts[i].geom.g1), dGeomGetBody(contacts[i].geom.g2));
}
numCollisions = dCollide(ball2, ball, NUM_CONTACTS, &contacts[0].geom, sizeof(dContact));
for(i = 0; i < numCollisions; ++i)
{
contacts[i].surface.mode = dContactBounce | dContactApprox1;
contacts[i].surface.mu = 250;
contacts[i].surface.bounce = 0.6;
contacts[i].surface.bounce_vel = 0.15;
dJointID c = dJointCreateContact(world, jgroup, &contacts[i]);
dJointAttach(c, dGeomGetBody(contacts[i].geom.g1), dGeomGetBody(contacts[i].geom.g2));
}
numCollisions = dCollide(box, plane, NUM_CONTACTS, &contacts[0].geom, sizeof(dContact));
for(i = 0; i < numCollisions; ++i)
{
contacts[i].surface.mode = dContactBounce | dContactApprox1;
contacts[i].surface.mu = 250;
contacts[i].surface.bounce = 0.6;
contacts[i].surface.bounce_vel = 0.15;
dJointID c = dJointCreateContact(world, jgroup, &contacts[i]);
dJointAttach(c, dGeomGetBody(contacts[i].geom.g1), dGeomGetBody(contacts[i].geom.g2));
}
numCollisions = dCollide(box, ball, NUM_CONTACTS, &contacts[0].geom, sizeof(dContact));
for(i = 0; i < numCollisions; ++i)
{
contacts[i].surface.mode = dContactBounce;
contacts[i].surface.mu = 250;
contacts[i].surface.bounce = 0.1;
contacts[i].surface.bounce_vel = 0.15;
dJointID c = dJointCreateContact(world, jgroup, &contacts[i]);
dJointAttach(c, dGeomGetBody(contacts[i].geom.g1), dGeomGetBody(contacts[i].geom.g2));
}
numCollisions = dCollide(ball2, box, NUM_CONTACTS, &contacts[0].geom, sizeof(dContact));
for(i = 0; i < numCollisions; ++i)
{
contacts[i].surface.mode = dContactBounce | dContactApprox1;
contacts[i].surface.mu = 250;
contacts[i].surface.bounce = 0.2;
contacts[i].surface.bounce_vel = 0.15;
dJointID c = dJointCreateContact(world, jgroup, &contacts[i]);
dJointAttach(c, dGeomGetBody(contacts[i].geom.g1), dGeomGetBody(contacts[i].geom.g2));
}
}
//--------------------------------------------
void FrameDraw( float fScale )
{
// 3D Viewport
m_pEngine->ViewportMake3D( 0.1f, 1000.0f );
m_pEngine->ClearScreen( );
// Enable light
glEnable(GL_LIGHTING);
// To receive values
const dReal *p;
// Setup camera
gluLookAt(10,10,100,0,0,0, 0,1,0);
/* DRAW SPHERE 1 AND 2 */
glColor4f(0.6,0.6,0.6,1);
glPushMatrix( );
p = dBodyGetPosition(ballBody);
glTranslatef(p[0],p[1],p[2]);
glutSolidSphere(BALL_RADIUS,20,10);
glPopMatrix( );
glPushMatrix( );
p = dGeomGetPosition(ball2);
glTranslatef(p[0],p[1],p[2]);
glutSolidSphere(BALL_RADIUS*5,30,10);
glPopMatrix( );
/* DRAW BOX */
glPushMatrix( );
// TEMPORARY
const dReal* rot;
const dReal* pos;
rot = dBodyGetRotation( boxBody );
pos = dBodyGetPosition( boxBody );
GLfloat matrix[16];
matrix[0] = rot[0];
matrix[1] = rot[4];
matrix[2] = rot[8];
matrix[3] = 0;
matrix[4] = rot[1];
matrix[5] = rot[5];
matrix[6] = rot[9];
matrix[7] = 0;
matrix[8] = rot[2];
matrix[9] = rot[6];
matrix[10] = rot[10];
matrix[11] = 0;
matrix[12] = pos[0];
matrix[13] = pos[1];
matrix[14] = pos[2];
matrix[15] = 1;
glMultMatrixf( matrix );
glutSolidCube( 8 );
glPopMatrix( );
// Disable light
glDisable(GL_LIGHTING);
// Draw floor
glBegin(GL_QUADS);
glVertex3f( -100, 0, -100 );
glVertex3f( 100, 0, -100 );
glVertex3f( 100, 0, 100 );
glVertex3f( -100, 0, 100 );
glEnd( );
}
//--------------------------------------------
private:
float m_fRotate;
CEngine* m_pEngine;
CTexture* m_pTexture;
SInputContainer m_keyQuitGame, m_keyYAxis, m_keyXAxis, m_keyReset;
CGraphicalUserInterface *m_pGUI;
} g_cTestScene;
// ...
======================================================================
Thanks for every help :)
--
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer
--
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer
--
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer
More information about the ODE
mailing list