Rotating wheel against a plane does not move!!

3 views
Skip to first unread message

Al Sabawi

unread,
Nov 19, 2009, 9:17:32 PM11/19/09
to ode-...@googlegroups.com

Hi

It is as though there is Zero friction!! The wheel is rotating correctly and I keep inducing the spin with

dBodySetAngularVel(ob[i].body,800,0,0);


but it spins in place against the bottom plane created with this

    // Bottom
    mw->ground = dCreatePlane (mw->space,0,0,1,0);

Here is my collision function :

void nearCallback (void *data, dGeomID o1, dGeomID o2)
{

    int nCat1, nCat2;
    int nContactsMade = 0;
    const int nMaxContacts=100;
    dContact contact[nMaxContacts];
    my_world *mw = (my_world *) data;

    bool bBounce = true;
   
    // Sanity check that these OLE objects exist
    if(!o1 || !o2)
    {
        return;
    }

    if (dGeomIsSpace(o1) || dGeomIsSpace(o2))
    {
            // colliding a space with something
        dSpaceCollide2(o1,o2,data,&nearCallback);
            // Note we do not want to test intersections within a space,
            // only between spaces.
        return;
    }

    nCat1 = dGeomGetCategoryBits(o1);  // Category for body1
    nCat2 = dGeomGetCategoryBits(o2);  // Category for body2


    // Check for collisions and return contacts
    nContactsMade = dCollide (o1,o2,nMaxContacts,&(contact[0].geom),sizeof(dContact));
   
    if (nContactsMade > 0)
    {

        // Process each of the contacts made in this collision
        for (int i=0; i<nContactsMade; i++)
        {

            // Set the flags to allow us to control the properties of the this contact surface
            contact[i].surface.mode = dContactBounce | dContactSoftCFM | dContactSoftERP ;

            // DEFAULT VALUES SET BELOW: Change them if needed for each specific collision bodies
            contact[i].surface.bounce      = 0.95f;    // 0: Not Bouncy, 1:Max bounceness
            contact[i].surface.bounce_vel = 0.0001f;    // Minimum bounce velocity, don't bounce if less
            contact[i].surface.soft_cfm   = 0.0001f;// 0: Very hard body, 1: Max softness
            contact[i].surface.soft_erp   = 0.95f;    // Error reduction parameter (ERP) also for softness
            contact[i].surface.mu = 1000;
            //contact[i].surface.mu2 = 0.0f;   

            // Bounce off one another and go your marry way
            dJointID c = dJointCreateContact (mw->world,mw->contactgroup,&contact[i]);
            dJointAttach (c,dGeomGetBody(o1), dGeomGetBody(o2));
        }
    }
}

What am I doing wrong ??

Bruce Veazie

unread,
Nov 20, 2009, 5:41:50 PM11/20/09
to ode-...@googlegroups.com
You may need to set the collide bits as well as the category bits. Does dCollide return any contacts?

--

You received this message because you are subscribed to the Google Groups "ode-users" group.
To post to this group, send email to ode-...@googlegroups.com.
To unsubscribe from this group, send email to ode-users+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ode-users?hl=.

seedhom

unread,
Nov 21, 2009, 5:18:33 AM11/21/09
to ode-users


On Nov 20, 5:41 pm, "Bruce Veazie" <bjvea...@veazie.org> wrote:
> You may need to set the collide bits as well as the category bits. Does dCollide return any contacts?

Yes. dCollide returns many contacts. However, I found what the
problem was and fixed it. There were 2 vertical planes I put in the
code when I was experimenting earlier. They were on each side of the
wheel which I thought I commented out. They were of course restraining
the movement and that is why it was spinning in place ;-(. Removed
them and now the wheel is rolling. my bad!!

I am assuming (but have not tried yet) that I could have used
dGeomSetCategoryBits() on my planes and filtered them at collision
callback. That would have saved me some debug time!!
Reply all
Reply to author
Forward
0 new messages