[ODE] Questions about representing motion in ODE

Jon Watte (ODE) hplus-ode at mindcontrol.org
Sun Mar 12 20:04:52 MST 2006


> From your experience, how would you model something like that in ODE? I'd prefer
> it were a simple way. I haven't made wrappers for the joints yet either so I'd
> prefer not to use them for now.

I would model this as two forces:

1) A drag force that acts contrary to speed. I'd probably make this 
linear with linear velocity, rather than square of velocity (as would be 
physically accurate). In vector algebra:

F = body.linearVel()*-0.01*body.mass();
body.addForce(F);

2) A forward-correcting force, that removes some percentage of movement 
that's not parallel with the forward vector. This means that, if you 
turn the sub, it'll swerve to move towards the new front. In vector algebra:

F = dot(body.linearVel(),body.orientation().right())*-0.05*body.mass();
body.addForce(F);

For a submarine, I'd probably model the depth as a desired depth, and 
add a force towards the desired depth that depends on the distance to 
the depth and the current velocity. An alternative is to just do the 
same thing as for sideways force (in case 2 above).

> Also, is there a better way to model the sub's rotation? For now, I just get yaw
> and pitch from reading the mouse and change m_Direction (and other vectors) to
> reflect that, but would it be better if I applied for example a torque or
> something like that? How would I do that to get what I want?

Use a controller. You want rotation X, but you currently have rotation Y 
with rotational velocity R. Apply a torque which is proportional to 
(X-(Y+R*TimeStepSize)), each step. This will make the sub "trend" 
towards the rotation you want. This works fine in euler angles, although 
there is some inaccuracy due to the cubic as opposed to square 
coordinates). In an arcade game, nobody will notice.

Cheers,

			/ h+


More information about the ODE mailing list