Modelling a servo motor: AngularMotorJoint Problems

TheNinja

02-12-2007 01:17:13

I'm trying to make a robot which is using some servo motors for the legs. I started with a hinge joint, which is working fine, except the bodies shouldn't be moved until i say so (but gravity and others forces are doing their part here).
Setting an angle on the hinge is also a problem, so I tried the AngularMotorJoint, which has the setAngle function. But so far I couldn't get it moving/changing the angle.
My code for the hinge and the motor:


OgreOde::JointGroup * jg = new OgreOde::JointGroup(mSim);

mHinge = new OgreOde::HingeJoint(mSim, jg);
mHinge->attach(body2);
mHinge->setAnchor(Ogre::Vector3(0,30,0));
mHinge->setAxis(Vector3(0,0,1));

mAMJ = new OgreOde::AngularMotorJoint(mSim, jg);
mAMJ->setAnchor(Ogre::Vector3(0,30,0));
mAMJ->attach(body2);
mAMJ->setAxis(0,OgreOde::AngularMotorJoint::RelativeOrientation_GlobalFrame,Vector3(0,0,1));
mAMJ->setAxisCount(1);
mAMJ->setMode(OgreOde::AngularMotorJoint::Mode_UserAngularMotor);
mAMJ->setAngle(0, Ogre::Math::DegreesToRadians(-60));
mAMJ->setParameter(OgreOde::Joint::Parameter_MaximumForce, 150, 0);
mAMJ->setParameter(OgreOde::Joint::Parameter_MotorVelocity, 150, 0);


Any help would be much appreciated.

EDIT: fixed the mixup with degrees and radians.
Looked through the forums some more, but couldn't find a flaw in my code. Got anybody a working AMJ?

EDIT2: The Motor is working now (the code above is updated). I got the axis wrong, they are starting with 0, not 1 (although the default axis for setParameter is 1, which led me on the wrong path). setAxis just seems to define the current angle as the value you set. The AMJ doesn't even change it's angle, only the hinge does.

Anyway, does anybody has an idea how to make a hinge on which you can set the angle you want?