[ODE] what is wrong with amotor joint?

Krystian Ligenza s2562 at pjwstk.edu.pl
Tue Dec 5 09:22:11 MST 2006


> Krystian Ligenza wrote:
>> why posts regarding AMotor joint are left without answer? Please, if the
>> problem of AMotor joint is not with it's implementation, but in bad
>> understading of using it, then tell me, and I will be sure that it can
>> work good. But if there is no way to make it work good I would like to
>> know that and leave it.
>
> amotors are usually used in combination with another joint.
>
> E.g. a Hinge and AMotor on the same two bodies is very common.
>
> Then just read the Hinge angle.
>
> This is e.g. some sample code:
>
>   hinge = dJointCreateHinge(world, 0);
>   dJointAttach(hinge, hull_body, turret_body);
>   dJointSetHingeAnchor(hinge, initialpos[0]-0.95,
> initialpos[1],initialpos[2]+0.
> 2);
>   dJointSetHingeAxis(hinge, 0,1,0);
>   dJointSetHingeParam(hinge, dParamLoStop, 0.00*M_PI);
>   dJointSetHingeParam(hinge, dParamHiStop, 0.50*M_PI);
>   dJointSetHingeParam(hinge, dParamCFM,    0.0005);
>
>   amotor = dJointCreateAMotor(world, 0);
>   dJointAttach(amotor, hull_body, turret_body);
>   dJointSetAMotorNumAxes(amotor, 1);
>   dJointSetAMotorAxis(amotor, 0, 1, 0,1,0);
>   dJointSetAMotorParam(amotor, dParamVel, 0.0);
>   dJointSetAMotorParam(amotor, dParamFMax, 10000);
>   Bram


ok, with hinge, and universal AMotor should work good, but I experience
problems with AMotor joint with ball socket joint. Limit's are set in
range +/- Pi/2. But they don't work...I use euler mode, here are code:
/////////////////////////////////////////////
//create joints
joint.symJoint = dJointCreateBall(_world, _jointGroup);
joint.symJointLimit = dJointCreateAMotor(_world, _jointGroup);

//atach joints to bodys
dJointAttach(joint.symJoint,
	     dGeomGetBody(boneNod[joint.boneA].symModel),
	     dGeomGetBody(boneNode[joint.boneB].symModel));
dJointAttach(joint.symJointLimit,
	     dGeomGetBody(boneNodejoint.boneA].symModel),
	     dGeomGetBody(boneNode[joint.boneB].symModel));

//set anchor
dJointSetBallAnchor(joint.symJoint,MB_TO_ODE(jointEffPos[0]),
				   MB_TO_ODE(jointEffPos[1]),
				   MB_TO_ODE(jointEffPos[2]));

//set mode
dJointSetAMotorMode(joint.symJointLimit, dAMotorEuler);

//set axis
dJointSetAMotorAxis(joint.symJointLimit,0,1,jointEffRot(1,0),
jointEffRot		    (1,1), jointEffRot(1,2));
dJointSetAMotorAxis(joint.symJointLimit,2,2,jointEffRot(2,0),
jointEffRot		    (2,1), jointEffRot(2,2));

//set param
dJointSetAMotorParam (joint.symJointLimit, dParamLoStop, 		   		     
joint.loJointRange1);
dJointSetAMotorParam (joint.symJointLimit, dParamHiStop, 		      	     
joint.highJointRange1);
dJointSetAMotorParam (joint.symJointLimit, dParamLoStop, 		       	     
joint.loJointRange1);
dJointSetAMotorParam (joint.symJointLimit, dParamHiStop, 				     
joint.highJointRange1);
dJointSetAMotorParam (joint.symJointLimit, dParamLoStop2,
		      joint.loJointRange2);
dJointSetAMotorParam (joint.symJointLimit, dParamHiStop2,
		      joint.highJointRange2);
dJointSetAMotorParam (joint.symJointLimit, dParamLoStop2,
		      joint.loJointRange2);
dJointSetAMotorParam (joint.symJointLimit, dParamHiStop2,
		      joint.highJointRange2);
dJointSetAMotorParam (joint.symJointLimit, dParamLoStop3,
		      joint.loJointRange3);
dJointSetAMotorParam (joint.symJointLimit, dParamHiStop3,
		      joint.highJointRange3);
dJointSetAMotorParam (joint.symJointLimit, dParamLoStop3,
		      joint.loJointRange3);
dJointSetAMotorParam (joint.symJointLimit, dParamHiStop3,
		      joint.highJointRange3);
////////////////////////////////

I try to add torque to joint meet certain rotation using equation:
torque = Kp*(des – cur) – Kd*vel;
Kp and Kd are proportional and derivative gains, des and cur are the
current and desired joint angles, and vel is the current velocity of the
joint. Again for hinge and universal joints this work very nice, but for
Ball socket with AMotor this simply doesn't work. Body's start to shake.
What am I doing wrong? Maybe the problem is with euler mode? How to use it
in user mode? What I have to update?

Thanks
Krystian



More information about the ODE mailing list