programming our soccer-robot we found an annoying problem. It has not been mentioned here before, I think:
NXTRegulatedMotor.class will accelerate the motors if they are blocked. But afterwards, they won't slow down again.
As this class is used by the DifferentialPilot, there occurs the same problem.
If you aren't careful, some programs will cause the robot to spin around very fast once he encountered an obstacle.
A simple example:
- Code: Select all
import lejos.nxt.Button;
import lejos.nxt.Motor;
import lejos.robotics.navigation.DifferentialPilot;
public class Pilottest {
public static void main(String[] args) {
DifferentialPilot dp = new DifferentialPilot (8.35, 9.52, Motor.B, Motor.C, false);
dp.setRotateSpeed(50);
while (!Button.ESCAPE.isDown())
dp.rotateLeft();
}
}
The code has to be modified like this to provide a constant low speed, even if the robot is stopped for a moment by an obstacle:
- Code: Select all
import lejos.nxt.Button;
import lejos.nxt.Motor;
import lejos.robotics.navigation.DifferentialPilot;
public class Pilottest {
public static void main(String[] args) {
DifferentialPilot dp = new DifferentialPilot (8.35, 9.52, Motor.B, Motor.C, false);
while (!Button.ESCAPE.isDown()){
dp.setRotateSpeed(50);
dp.rotateLeft();
}
}
}
In this example the program applies (?? sry, I don't know the right English word) the speed in every turn. Therefore the robot slows down to the prescribed speed of "50", even if the NXTRegulatedMotors boost the speed a moment before because of an obstacle. And so the robot won't spin around in an abnormal high speed to overpower an obstacle that has already vanished.
In the end we fixed it by changing our code as shown in example 2. But we were thinking whether it wouldn't make sense to change the source code in a way, which will cause the NXTRegulatedMotors to turn the power down as soon as they are moving again. Maybe you have to rewrite parts of the Move.class to change this behavior, but we didn't investigate that far.
At least the problem should be mentioned in the API-documentation, shouldn't it?
It would be nice, if someone adopts our suggestion and fixes this problem.
Greetings from Rheinbach
