[ODE] Optimal orientation arrival

Darío Mariani mariani.dario at gmail.com
Thu Jun 30 10:13:31 MST 2005


More or less you have to do this:

dVector3 axis = <normalized axis in which it must be aligned>;
dVector3 vel = <velocity in local coordinates, normalized>;
dVector3 err = cross_product (vel, axis);        // The error
if (squared_length (err) == 0) return;  // If 0, it's aligned. Should
check if it´s aproximately 0
// Adjust err length proportional to the angle of the error, and invert it.
err = normalize (err);
err = err * - angle_between (axis, vel);
dReal ks = 0.1; // Damping constant
dReal kd = 1.5; // Spring constant
dVector3 torque = err * ks - global_angular_velocity * kd;
torque = inertia_tensor * force;  // This step could be skipped
// Adjust if the torque exeeds the maxium torque, alternatively, play
with ks and kd values
adjust (torque, MAX_TORQUE);

Sorry for the pseudocode, but my code is a couple of layers down my
abstractions.
Steal warning: This code was "stolen" from the SpringMotor in Opal
(http://opal.sf.net).

        Darío

On 6/30/05, Paul Bridger <paul.bridger at gmail.com> wrote:
> Hi,
> 
> I want to rotate a body to a given orientation as quickly as possible.
> The body has a maximum torque it can apply, and I want to work out
> what torque to apply at any given time.
> 
> I can calculate the axis of rotation, but I'm not sure how to
> calculate the torque I can apply as a factor of a body's rotational
> inertia etc.
> 
> Any hints?
> 
> Paul
> 
> _______________________________________________
> ODE mailing list
> ODE at q12.org
> http://q12.org/mailman/listinfo/ode
>



More information about the ODE mailing list