[ODE] joint motor(2)
whitt013
whitt013 at bama.ua.edu
Tue Mar 11 20:17:01 2003
Well, the slider is going to keep you constrained to always pointing "away"
from your starting location. So you'd have to ditch that idea if you wanted
to turn. You could add a couple spheres and hinge joints to the box to act as
wheels and make a simple car (see test_buggy). If you wanted to keep it to a
single box, I'm sure there's an equation that would give you the force you
need to set a force to once you reach the desired speed to maintain constant
velocity, based on friction, mass, and gravity (mass*gravity*mu????).
Here's an idea that might be a bit more fun. Fake wind resistance in your
system by adding a force in the opposite direction of the box's velocity, and
make the force a multiple of the square of the magnitude of it's velocity.
Then add forces to push it in the direction you want it to go, and it will
reach a "terminal velocity" once it gets to a certain speed. Adjust the
multiple to adjust the terminal velocity, and you have both constant velocity
and unrestricted rotation. Something like this:
//create "wind resistance"
dReal *velocity = dBodyGetLinearVel(box);
dReal k = 1.0; //this is the multiple. Increase for lower terminal
velocity
dBodyAddForce(k *
(velocity[0]*velocity[0]+velocity[1]*velocity[1]+velocity[2]*velocity[2]),
-velocity[0], -velocity[1], -velocity[2]);
//that is NOT physically correct!
//now you can add all the forces you wan to the body.
dBodyAddRelForce(100, 1, 0, 0); //the pushing force
dBodyAddForce(10, 0, 0, 1); //the steering force (assuming y is up)
Like I said, that is definitely not a physically correct model for wind
resistance, since it doesn't take into account the surface area or shape of
the item, but it is a "good enough" approximation if all you need is a
constant terminal velocity.
Hope that helps,
David
>===== Original Message From "kimyongsum" <vat832@hotmail.com> =====
>Hi:
>
>I got the box moving @ constant speed by using slider joint as David
suggested. Now I have a new question.
>What if I want to push the box one side harder than the other to cause the
box to turn (not only changing the direction) but still go at constant speed.
How can I achieve this?
>
>I think I can use dBodyAddRelForceAtRelPos on both sides the box to make it
turn but it'll go faster and faster.
>
>Thank you,