[ODE] dJointGetAMotorAngleRate..again

Krystian Ligenza kxxl at poczta.onet.pl
Fri Nov 17 15:28:22 MST 2006


Hi,

i was looking in archive why this method isn't implemented and couldny find 
answer. More, I found 2 implementation of this:

1st through the API:
//--------------------------------------------------------
dReal getAMotorAngleRate (dJointID joint, int anum) {
  dReal rate = 0;
  dBodyID b0 = dJointGetBody(joint, 0);
  dBodyID b1 = dJointGetBody(joint, 1);
  dVector3 axis;
  dJointGetAMotorAxis (joint, anum, axis);
  if (b0 != 0) {
    const dReal *avel0 = dBodyGetAngularVel(b0);
    rate += axis[0]*avel0[0] + axis[1]*avel0[1] + axis[2]*avel0[2];
  }
  if (b1 != 0) {
    const dReal *avel1 = dBodyGetAngularVel(b1);
    rate -= axis[0]*avel1[0] + axis[1]*avel1[1] + axis[2]*avel1[2];
  }
  if (b0 == 0 && b1 != 0)
    rate = -rate;
  return rate;
}
//-------------------------------------------------------

2nd internal implementation:
//-------------------------------------------------------
extern "C" dReal dJointGetAMotorAngleRate (dxJointAMotor *joint, int anum)
{
  dAASSERT(joint && anum >= 0 && anum < 3);
  dUASSERT(joint->vtable == &__damotor_vtable,"joint is not an amotor");
  if (joint->node[0].body) {
    dVector3 axis;
    dJointGetAMotorAxis (joint, anum, axis);
    dReal rate = dDOT(axis,joint->node[0].body->avel);
    if (joint->node[1].body) rate -= dDOT(axis,joint->node[1].body->avel);
    return rate;
  }
  else return 0;
}
//-------------------------------------------------------

but no one of them has a comment that:
- yes it's working good
- no, it' not working.

I have check this, and both implementation give the same result, which is 
for axis 0 and 2 it gives velocity, but axis 1 is always 0. It's becouse I'm 
using euler mode, and done exactly like uderguide say's:
-------------------------------------------
For dAMotorEuler mode:
. Only axes 0 and 2 need to be set. Axis 1 will be determined automatically 
at each time step.
. Axes 0 and 2 must be perpendicular to each other.
. Axis 0 must be anchored to the first body, axis 2 must be anchored to the 
second body.
-------------------------------------------

I have three questions:
- what is the problem with AMotor, I read a lot of complaint about it (in 
archive), but no description of problem?
- should I ever use AMotor with ball joint? if yes,
- how to compute angularVelocity for axis 1 ?

Thanks,
Krystian 



More information about the ODE mailing list