Open Dynamics Engine does not recognize collision between cylinders

2

I am using the ODE (Open Dynamics Engine) library to simulate physics in my application. To create the bounding box and cylinder geometry I am using the following code

dMass m1;
dMassSetZero(&m1);
dMassSetCappedCylinderTotal(&m1, mass, 2, lx/2.0, lz);
dBodySetMass(body, &m1);
dBodySetPosition(body, x0, y0, z0);
dBodySetRotation(body, R);

dGeomID geom = dCreateCylinder(PhysicsEngine::space, lx / 2.0, lz);
dGeomSetBody(geom, body);

No error is generated, and object is generated correctly. However when performing collision treatment:

const int N = 100;
dContact contact[N];
int n = dCollide(o1, o2, N, &contact[0].geom, sizeof(dContact));

for (int i = 0; i < n; i++) {
    contact[i].surface.mode = dContactSlip2 | dContactSlip1;
    contact[i].surface.mu = dInfinity;
    contact[i].surface.slip1 = 0.1;
    contact[i].surface.slip2 = 0.1;
    dJointID c = dJointCreateContact(PhysicsEngine::world, PhysicsEngine::contactgroup, &contact[i]);
    dJointAttach(c, dGeomGetBody(contact[i].geom.g1), dGeomGetBody(contact[i].geom.g2));
}

The engine recognizes collisions of:

  • Plane and Cylinder
  • Cube and Cylinder
  • Ball and Cylinder

but does not recognize Cylinder with Cylinder, as in the image

Doesanyonehaveanyideawhatitcanbe?Iamusingthecurrentversionofthelibrary,availableinthis repository and I used the following command to compile it

./premake4.exe --with-tests --with-libccd --with-demos vs2010
    
asked by anonymous 23.04.2018 / 19:12

1 answer

0

Thanks for the help of the comments. To resolve this issue I needed to recompile the ODE (Open Dynamics Engine) library along with the libccd (Library for collisions between convex objects). It turns out that ODE, as it currently depends on contributions, does not have a native collision implementation for cylinder to cylinder (because it is a convex object). But the libccd library can be compiled along with ODE to complement the engine, and libccd is used by other physical simulation libraries which you can find at article .

I would like to create a tutorial in Portuguese for this physical simulation engine. I'll explain step by step how to do this for Microsoft Visual Studio (2017) .

1. First you need to go to the ODE bitbucket repository and download the source code (compressed in tar.gz) and extract into some folder.

Open the command prompt and go to the build folder (cd ./folder/do/ode/build).

3. Run the command to generate the project for Visual Stuido by enabling the libccd

./premake4.exe --with-tests --with-libccd --with-demos vs2010

(Note, ODE currently has setting for vs2010 down but works in Visual Studio 2017)

4. The command will generate the project for visual studio in the ./ build / vs2010 folder and open ode.sln

>

5. Inside Visual Studio compile all projects (you may need to redirect the project to the SDK of your IDE).

6. In the main folder go to:

  • \ include , to add the two folders with header files to your project through Visual Studio settings, under VC ++ Directories > Inclusion Directory
  • \ lib \ DebugDoubleDLL , to add the files (minus the test files) to your project via Visual Studio settings in VC ++ Directories > Library Directory
Copy the ode_doubled.dll file into the executable output folder (to avoid errors), the file that is in the \ lib \ DebugDoubleDLL .

8. In your project, go to Project Settings > C / C ++ > Preprocessor > Preprocessor Definitions and add the dDOUBLE preprocessor

9. In your project, go to Project Settings > Binding > Entry > Add Dependencies and add the dependency ode_doubled.lib

10. ODE is already set up; for testing use this example of the demure tutor and my code in the question to create a cylinder.

Result:

    
25.04.2018 / 04:09