Collision detection on jointed objects

Hi,
I’m new to Ode & OdeJava (Hi Level API), and I notice that the collisions between 2 jointed bodies are not reported.
I have a very simple wordl with two boxes connected by an edge with a hinge joint, and when rotating around this joint, the boxes interpenetrate. If I remove the joint, though, they do not.
I recompiled all the OdeJava library, and noticed the following code in the nearCallback function of odejava.cpp:

// ignore if the two bodies are connected by a joint
if (b1 && b2 && dAreConnectedExcluding (b1,b2,dJointTypeContact)) return;

This test will prevent collision between jointed bodies to be reported. If I comment it out, my boxes behave OK.
Am I doing something wrong, or should the test rather ignore the collision if the bodies do not have any contatct joints ?

Thanks,
-Alex

looks like you’ve either found a bug or a feature :wink:

Jani will hopefully soon clarify the intend of that code :slight_smile:

If it’s not too much trouble can you post a small test case? Using the IssueZilla (http://odejava.dev.java.net/) is probably the best place to file bugs.

Will.

[quote]Hi,
I’m new to Ode & OdeJava (Hi Level API), and I notice that the collisions between 2 jointed bodies are not reported.
[/quote]
This is the current behaviour of Odejava.

Current nearCallback is an example, it won’t work on all simulations. It does however suit fine for many simulations. The biggest questionable nearCallback ‘feature’ is this “ignore jointed bodies” part that you have found. Easiest way is to offer two different callbacks on Odejava in order to satisfy most users needs.

Some people like to ignore bodies that are connected to each other with a joint, e.g. a car wheel should not hit to chassis at any case when wheel is connected to the car chassis with an joint. This is how current Odejava nearCallback acts.

Some people would like to handle also these kind of collisions, this is your case and Odejava does not work this way.

Fast fix would be for me to add various nearCallbacks to Odejava but this is not too sound solution. I would have to think this a bit before implementing anything. Pure java collision class on Odejava (java nearCallback) is most flexible way to define your callback but it’s also the slowest. Also it’s not quite yet finished, even though it’s easy to finish.

Ok, thanks for your answers.
I guess I’ll start using my own callback function :slight_smile:
Thanks again,
-Alex

I’d like to throw in my support for collision detection between jointed objects. This is pretty important to my in-game entity. If you’re concerned about speed with the callback on the Java side, perhaps this could be supplied as a flag to the C++ side?

an extra boolean argument to the method would probably work - don’t think JNI works well with global “flags”. You could have a seperate binary but that seems pointless.

Will.

I’ll resolve this “problem” the next time I compile new Odejava library. Probably I’ll throw in one or couple switch that affect to the callback.

Also autodisabling needs to be committed and new collision classes, these have been waiting on my Eclipse project for a month now…

Hi!
I need collision detection between joinded objects. Now has been a while since this was posted. Has something changed on this topic?

How can I generate those contact points if two joined bodies collides?

Thanx,
Christian

Ok,… anyhow I found out that there is a class “PureJavaCollision”, where I can implement my own calback function. I have no idea how to do it. Could anyone help please!?

As I know, I have to extend the class mentioned above and implement the callback like this:

public void nearCallback(int arg0, int arg1) {

	OdeConstants. SWIGTYPE_p_dGeomID o1 = Ode.dSpaceGetGeom(space.getId(), arg0);
	SWIGTYPE_p_dGeomID o2 = Ode.dSpaceGetGeom(space.getId(), arg1);
	
	if ( o1 != null && o2 != null) {

// colliding two non-space geoms, so generate contact
// points between o1 and o2
int num_contact = dCollide (o1,o2,16,contact_array,skip);
}
}

As I said, I have no further idea…

Thanx,
Christian