odejava - contact joint feedback

Is there a way to get org.odejava.JointFeedback data from contacts, even if it’s not currently supported by the org.odejava package and I have to go through the lowevel org.odejava.ode.Ode class?

I need to find the impulse at places of contact. I can get this from the force at the contact and the step size.

Ok, I’ve almost figured it out. It’s a little rough, but only a “proof of concept”. I don’t know if it works, because I haven’t been able to test it yet since my system framework isn’t complete enough.

After calling the collide(Space) method on a JavaCollision instance, you iterate over the Contact class.

For each iteration, you create a dContact instance and use the Ode.dJointCreateContact method to return a SWIGTYPE_p_dJointID instance. Create a dJointFeedback instance, which can be applied to the constructor for JointFeedback. Use Ode.dJointSetFeedback on the SWIGTYPE_p_dJointID instance and the dJointFeedback instance. Use Ode.dJointAttach to attach the joint to the two bodies.

Now step your simulation, and you (hopefully) can read in up-to-date and correct JoinFeedback data.

Note: You won’t need to ever call applyContacts() on a JavaCollision instance since we apply then manually.

Any comments?

what do you think is the best way to wrap this functionality in the high level API?

Will.

To wrap this functionality the way it is, perhaps create a JointContact class which accepts and uses a Contact instance to fill its properties. The user can then call the inherited (perhaps overriden) methods from the Joint class such as enableFeedbackTracking(), attach(Body, Body) and getFeedback().

It’s a little hard to say since I wouldn’t have created the high level collision API in quite the way it is now.

I would have created some sort of CollideListener interface which contains something like ode’s nearCallback as its method. Instead of the user calling collide(Space), they would actually call collide(Space, CollideListener) or something to that extent. This would also require a collide method somewhere in the high level API which works like ode’s dCollide function.

This would allow the user to create their own contact joints as they see fit. For example, the default nearCallback for odejava ignores contacts when the two touching bodies are connected by a joint. However, sometimes it is desirable to still create a contact especially if that joint is somehow separated from the two bodies (such as a distant hinge joint).

However, this would require a java method call from the c side of JNI, and I don’t know what the performance impact of that would be. If the impact is unacceptable, then I understand the need for the current high level collision API using buffers from NIO.