Open Dynamics Engine does not recognize collision between cylinders

Asked

Viewed 49 times

2

I’m using the library ODE (Open Dynamics Engine) 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 handling:

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:

  • Flat and Cylinder
  • Cube and Cylinder
  • Ball and Cylinder

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

ODE não reconhecendo colisões entre cilindros

Does anyone have any idea what it might be? I’m using the current version of the library, available in this repository and used the following command to compile it

./premake4.exe --with-tests --with-libccd --with-demos vs2010
  • Take a look at the library’s own wiki documentation in the section Collision Tests Supported. There is a note (note 3) saying that collisions between cylinders require the libccd is enabled. Maybe that’s what’s missing.

  • Only now have I noticed that in your command line you actually already include the libccd. Well, other than that, maybe you’re picking up Dlls from a wrong place? Another thing: your "collision treatment" actually creates Joints. The problem is in the creation of the Joints or in fact the call of dCollide not working? Debug to be sure.

  • @Luizvieira Valeu, it worked fine. I had recompiled, but I only updated the headers (.h) and the libraries (.lib), but I didn’t update the DLL. As I did not present errors I thought everything was in order

  • https://imgur.com/a/xyjOWwT

  • The collision treatment takes place in a loop, and recovers all collisions with dCollide, then I configure the forces through dCreateContact

  • I’m glad it worked. Good luck.

Show 1 more comment

1 answer

0


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

I take the opportunity to create a tutorial in Portuguese for this physical simulation engine. I will explain step by step how to do this Microsoft Visual Studio (2017).

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

2. 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 activating the libccd option

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

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

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

5. Within Visual Studio Embed all projects (you may need to redirect the project to your IDE’s SDK).

6. In the main folder go to :

  • \include, to add the two folders with header files to your project through Visual Studio settings, at VC++ Directories> Inclusion Directory
  • \lib Debugdoubledll, to add the files (less the test ones), to your project through the settings of Visual Studio, in VC++ Directories> Library Directory

7. Copy the file ode_doubled.dll in the executable output folder (to avoid errors), file that is in the folder \lib Debugdoubledll.

8. In your project, go on Project Settings > C/C++ > Preprocessor > Preprocessor Settings and add the pre-processor dDOUBLE

9. In your project, go on Project Settings > Linker > Input > Additional Dependencies and add dependency ode_doubled.lib

10. The ODE is already configured to test use this example from demo tutorial and my code on the question to create a cylinder.

Upshot:

inserir a descrição da imagem aqui

Browser other questions tagged

You are not signed in. Login or sign up in order to post.