[ODE] Calculating G force
Deak Szabolcs
ancient at ludens.elte.hu
Mon May 8 08:15:42 MST 2006
Well, I'm not that much of an authority here, but I might add a few
thoughts.
1, I presume you are aware that you won't get the actual so-called
"G-Forces" with this calculation because those are relative to the the
gravitational acceleration constant, so you should devide your results
with g.
2, There is an actual real nasty problem with the code presented here
and it actually took me quite a long time to notice it :)
What you do is you take the *body-relative* velocity vectors at each
timestep and subtract them to find the velocity difference and thus the
acceleration. While the method of dividing the velocity difference with
time to get (average) acceleration is OK, doing that with body-relative
velocities isn't!
Let me explain with two obvious examples:
a, you have a body moving on a circlular path with a constant speed,
always heading (pointing) towards the tangent of the circle. At every
instance in time the velocity of the object in the body-relative frame
will always point straight ahead, so differences would always lead to
zero acceleration even though there certainly is an acceleration keeping
the object on a circular path.
b, even more obviously if you have an object moving at a constant speed
(thus no G-forces) and spin the object around then the relative velocity
vectors sampled at different times might be pointing anywhere falsely
reporting acceleration.
The fix is simple, make the subtraction in the world frame and then
convert the difference to body-relative coordinates!
This would also have a small error as the difference vector would not be
perfectly perpendicular to the object in example a, but you would like
the results much better I guess :)
(I won't go into the case of the acceleration felt by a point on an
object offset from its center of gravity, but from what I see that was
not your intention anyway)
Anders Olofsson wrote:
>Well, it didn't work that good.. Am I thinking this all wrong?.
>
>dVector3 vel,oldvel,force;
>void CalculateGForces (dBodyID body)
>{
> const dReal *tmp;
> dVector3 tmpv;
>
> tmp=dBodyGetLinearVel (body);
> dBodyVectorFromWorld (body, tmp[0], tmp[1], tmp[2], tmpv);
> vel[0]=tmpv[0];
> vel[1]=tmpv[1];
> vel[2]=tmpv[2];
> if (dtime>0){
> force[0]=(vel[0]-oldvel[0])/dtime;
> force[1]=(vel[1]-oldvel[1])/dtime;
> force[2]=(vel[2]-oldvel[2])/dtime;
> }
> oldvel[0]=vel[0];
> oldvel[1]=vel[1];
> oldvel[2]=vel[2];
>}
>
>_______________________________________________
>ODE mailing list
>ODE at q12.org
>http://q12.org/mailman/listinfo/ode
>
>.
>
>
>
More information about the ODE
mailing list