[ODE] Ball and Socket or (Universal +Hinge)

Jaap Stolk jwstolk at gmail.com
Mon Apr 10 14:22:45 MST 2006


On 4/10/06, Jaap Stolk <jwstolk at gmail.com> wrote:
> I get no errors for dJointGetAMotorAngle(), but the result is always
> zero. is this one also not implemented for dAMotorUser ?

maybe i always get a zero angle because i set the motor up wrong ?
setting the directly seems to have the expected effect in the
simulation, so the motor is doing "something". My code looks about
like this: (joints are actually stored in an array)

#define AXIS_GLOBAL      0
#define AXIS_FIRST_BODY  1
#define AXIS_SECOND_BODY 2
  dBodyID  body0, body1;
  dJointID joint, jointMot;

  // ball joint:
  joint = dJointCreateBall(world,0);
  dJointAttach(joint, body0, body1);
  dJointSetBallAnchor(joint, joint_x, joint_y, joint_z);
  // add a motor to contol the 3 axes of rotation:
  jointMot = dJointCreateAMotor(world,0);
  dJointAttach(jointMot, body0, body1);
  dJointSetAMotorMode(   jointMot, dAMotorUser);
  dJointSetAMotorNumAxes(jointMot, 3);
  dJointSetAMotorAxis(   jointMot, 0, AXIS_FIRST_BODY, 1,0,0);
  dJointSetAMotorAxis(   jointMot, 1, AXIS_SECOND_BODY,0,1,0);
  dJointSetAMotorAxis(   jointMot, 2, AXIS_SECOND_BODY,0,0,1);
  dJointSetAMotorAngle(  jointMot, 0, 0.0);
  dJointSetAMotorAngle(  jointMot, 1, 0.0);
  dJointSetAMotorAngle(  jointMot, 2, 0.0);

  //then before each simulation step:
  ang_x  = dJointGetAMotorAngle(    jointMot,0); // (always zero ?)
  angv_x = dJointGetAMotorAngleRate(jointMot,0); // (not implemented)
  ang_y  = dJointGetAMotorAngle(    jointMot,1); // etc.
  angv_y = dJointGetAMotorAngleRate(jointMot,1);
  ang_z  = dJointGetAMotorAngle(    jointMot,2);
  angv_z = dJointGetAMotorAngleRate(jointMot,2);

  dJointAddAMotorTorques(jointMot, torque_x, torque_y, torque_z);

is there something missing in the motor initialization ?

Jaap



More information about the ODE mailing list