I made a very simple simulation of a robot (a dog) with 14 hinge joints,
each body is a cube, except the foots that are spheres (for the collision with the floor), the floor is a cube
I found that to get joints' error smaller ( < 0.001 radian) I had to set timeStep = 0.001, and the solver.num_iteration >= 50
the problem is that the simulation is quite slow (9 times the real rate, witch is not enough to perform a great number of simulation for genetic algorithm)
the joints are set to a specific angle like that :
Code: Select all
void SetJointToSpecificAngle(float desiredAngle, float maxVelocity, btHingeConstraint * joint, float timeStep)
{
float velocity;
float currentAngle = joint->getHingeAngle();
float angError = desiredAngle - currentAngle;
if (angError > 0) velocity = maxVelocity;
else velocity = -maxVelocity;
if (fabs(angError) <= maxVelocity * timeStep)
{
velocity *= fabs(angError)/(maxVelocity * timeStep);
}
// joint->setLimit(1,0); <=> No Limit !
joint->enableAngularMotor(true,velocity,100); // 100 : max impulse
}
thanks