This is probably what you're looking for:
isStalled()
NXTRegulatedMotor.isStalled()
- Return true if the motor is currently stalled. (i.e. move count shows less rotation degrees than expected)
http://www.lejos.org/nxt/nxj/api/lejos/nxt/NXTRegulatedMotor.html#isStalled()
Another method you should be aware of is this:
setStalledThreshold()
NXTRegulatedMotor.setStallThreshold()
- Set the parameters for detecting a stalled motor. A motor will be recognised as stalled if the movement error (the amount the motor lags the regulated position) is greater than error for a period longer than time.
http://www.lejos.org/nxt/nxj/api/lejos/nxt/NXTRegulatedMotor.html#setStallThreshold(int, int)
And finally here's an example of how to put it all together:
public static void main(String[] args)
{
boolean stalled = false;
NXTRegulatedMotor motor_arm = Motor.A;
motor_arm.setStallThreshold(1, 100);
motor_arm.setSpeed(400);
motor_arm.backward();
while (! stalled)
{
LCD.drawString("Motor is rotating", 0, 0);
if(motor_arm.isStalled())
{
motor_arm.stop();
stalled=true;
LCD.drawString("Motor is stalled", 0, 0);
Delay.msDelay(3000);
}
Delay.msDelay(100);
}
}
Notice: The values for setStalledThreshold()
are likely to be mechanically-dependent, if you use gears to connect the motor to the stalling mechanism the values for correct stall detection may vary according to the design of your robot.
Good luck! :)