[ODE] Rotation troubles

Nicholas Francis nicholas at uti.is
Thu Dec 25 17:07:20 MST 2003


Hi Guys...

Sorry to bother you, but I've run into this problem that I just cannot 
figure out:

I want to create a 'directional motor'. It should work like this:

I set a target rotation, and a max torque to apply to a rigid body. The 
object of the motor is then to orient the rigid body so it has a 
rotation that matches the target, and 0 angular velocity (in practice 
this means that the angular velocity of the rigid body should increase 
for half the turn distance and then decrease for the other half).

As an example of what we're trying to accomplish with this, imagine an 
ODE/AI controlled enemy helicopter. We want it to 'do its best' to keep 
the gun (=forward direction) aligned with the player, and the having a 
limited rotational power to accomplish this with. This implies that the 
target position will change continously.

I can do this either applying torque to a rigid body outside the main 
ODE loop, or create a joint. As Im not 'into' ODE (we just integrated 
it wholesale into our 3D engine ;-), I would be inclined to do the 
first.

So far, I can easily get the helicopter to turn towards the player, but 
it overshoots. I tried to calculate the rotation of the helicopter in 1 
second, and start braking if I could see it had turned too far. This 
hack worked fine until something hit the helicopter, sending it 
spinning wildly. At this point, the 1 second  sometimes resulted in a 
positive feedback loop, only worsening the rotation. After trying to 
adjust the '1 second lookahead' by the angular velocity of the object, 
I gave up, and am now looking for a more 'correct' approach - hence 
this mail

Have anybody out there done anything similar? If so, Id love some help

TIA,
Nicholas



More information about the ODE mailing list