Joint motor

Hugo Peixoto

16-03-2008 18:11:55

Hey there, I'm trying to implement a hinge joint motor.
Currently, I have set a custom callback for a normal Hinge,
which calculates an acceleration and calls setCallbackAccel
on the joint.
Unfortunately, the way I'm calculating the acceleration isn't
very realistic:

Real accel = joint->calculateStopAlpha(Radian(Degree(angle)));

where angle is the angle I want to move to.
I wanted something more like "add a torque of X to the joint",
so that it would have in account all the forces being applied to both
bodies, in the simulation. (in order to avoid an unlimited strength joint)

What is the correct way of doing this?

Best regards,
Hugo Peixoto.

Hugo Peixoto

18-03-2008 12:28:43

I currently have this:


void motor(BasicJoints::Hinge * joint)
{
HingeMotor * motor = (HingeMotor * )joint->getUserData();
if (!motor)
return;

Real accel = joint->calculateStopAlpha(motor->getAngle());
accel = accel > 0 ? min(accel, Real(20.0)) : max(accel, Real(-20.0));

joint->setCallbackAccel(accel);
motor->step();
}


But it just doesn't seem very right... Am I doing it wrong?

Best regards,
Hugo Peixoto.