Home | Tutorials | Wiki | Issues
Ask Your Question

Revision history [back]

Try to print the force applied to robot, if the force was so high perharps this is the problem.

If your robot is moving back, probably the force applied is negative.

double target_dist = 2.0;

 if (min_dist < this->laser->GetRangeMax())
{
     double torque = this->gain*( min_dist - target_dist );
     this->leftWheelJoint->SetForce(0, torque);
     this->rightWheelJoint->SetForce(0, torque);
}

Print the min_dist value and target_dist to ensure what values are being used.