[ODE] Newbee -> Infinite, and Not a Number errors

thama thama at auth.gr
Tue Sep 6 13:19:11 MST 2005


I have just started to use ODE and I have tried to experiment with
a world with gravity.

    dWorldID myworld = dWorldCreate();
    dWorldSetGravity (myworld, 0, -9.84, 0);
    dBodyID body = dBodyCreate (myworld);
    int ms;
    dMass *mass = ReadFile(argv[1], ms);
    dBodySetMass (body, mass);
    dBodySetPosition (body, 0, -32, 0);
    dQuaternion q;
    dQSetIdentity(q);
    dBodySetQuaternion (body, q);
    dBodySetLinearVel (body, 0, 0, 0);
    dBodySetAngularVel (body, 0, 0, 0);
    bool chk = false;
    dReal *v, *w, *p;
    for(int ff = 0; ff< 10000; ff++)
    {
        int f;
        f = setforces(body) - 2*ms;
        dWorldStep (myworld, 0.001);
        v = (dReal *)dBodyGetLinearVel (body);
        w = (dReal *)dBodyGetAngularVel (body);
        p = (dReal *)dBodyGetPosition (body);
        std::cout << ff << ".p = "<<p[0] << ',' << p[1] << ',' << p[2] 
<< '\t' << "v = "<<v[0] << ',' << v[1] << ',' << v[2] << '\t'<< "w = "<< 
w[0] << ',' << w[1] << ',' << w[2] << '\n' ;
    }
    where ReadFile function just reads a file and which contains the
    mass and the inertia tensor of a body. The function setforces
    contains the following ODE function

    int setforces(dBodyID &b)
    {
    ......
    dBodyAddForceAtRelPos (b, 0.0, A, 0.0, xA, yA, zA);
    ....
    }

    After two or three iteration (depends on the parameters) the
    angular velocity takes value of QNAN or INF.

    Why this happens ?
    Do I forget anything ?

    Thank you in advance.



More information about the ODE mailing list