This is my first post on Lejos forum, I apologise in advance for poor English.
I'm working on smoothing of NXT moves and I think I found two bugs in the NXTRegulatedMotor class.
1. In my opinion, motor should suspend regulation without breaking.
I mean suspending regulation shouldn't have any impact on current move. Reality shows something different.
So this is the first bug.
2. Also, this motor should know actual current position, instead of remember the last one from regulated mode.
And this is the second bug.
On the short movie we can see violent break after calling suspendRegulation(). In addition, method rotate() doesn't refresh its data.
That is why it rotates circa 270 deg, instead of 360.
A link to movie with described test is here:
http://youtu.be/8u6T623lROc
I attach source code at the botom:
- Code: Select all
import lejos.nxt.LCD;
import lejos.nxt.Button;
import lejos.nxt.MotorPort;
import lejos.nxt.NXTRegulatedMotor;
import lejos.util.Delay;
public class Parametr {
public static void main(String[] args){
NXTRegulatedMotor right = new NXTRegulatedMotor(MotorPort.A);
right.forward();
//rotate until tire has max momentum (inertia plus gravity)
while( right.getTachoCount() < 360 * 0.75 ){
Thread.yield();
}
//save position, where you want to give up regulation
LCD.drawInt(right.getTachoCount(), 0,0);
right.suspendRegulation();
// allow the motor to move freely for 2 seconds
Delay.msDelay(2000);
//get the position, where it actually is
LCD.drawInt(right.getTachoCount(), 0,1);
//and make one more round
right.rotate(360);
LCD.drawInt(right.getTachoCount(), 0,2);
Button.waitForAnyPress();
System.exit(0);
}
}
Values on LCD were: 270, 372, 640. So "rotate(360)" moved motor only by: 640 - 372 = 268 degrees.
I hope my test will help leJOS team to improve next release
ps.
This isn't new issue, I read connected thread "0.9.0 resetTachoCount()" here:
http://lejos.sourceforge.net/forum/viewtopic.php?f=7&t=2735&hilit=resetTachoCount
