Constraining angle between two bodies

zbethel
Posts: 6
Joined: Sun Jul 01, 2012 5:15 am

Constraining angle between two bodies

Post by zbethel »

Alright, I posted something similar about this recently, but didn't get a response. I'm going to try again and be a little more specific. So I've got a working demo of a tank. The wheels are locked together using a series of distance constraints to force them to rotate at the same angle. Here's what I mean:

Image

So between each pair of wheels, there are two distance constraints 90 degrees from each other. This way, when one of the wheels turn, it exerts forces on all the other wheels. This allows them to all rotate in sync. To power the tank, I apply torque to the back wheel. This simulation works okay until the tank starts moving quickly, and then it becomes unstable or even locks up. I'm wanting to implement a simple constraint that checks the angle difference between two bodies (even just along the local X axis) and applies a counter force. Either that, or detect the torque impulse on one of the wheels and apply a counter force that way.

Looking at the constraint solver for the distance constraints, it appears to find the distance error vector and put it into the jacobian matrix. I have no idea what the jacobian is doing exactly. Could someone point me in the right direction on how to go about writing a "distance" constraint that relies on the relative angle between two bodies instead of two points?

Thanks!