I have some difficulties to find an approach an object with the ultrasonic sensor. I've made a little code to perform that, but it doesn't working. Here is it :
- Code: Select all
import lejos.nxt.*;
import lejos.robotics.navigation.DifferentialPilot;
public class AlgoFindBall
{
public static void main(String[] args){
DifferentialPilot pilote = new DifferentialPilot(5.5, 17, Motor.A, Motor.B);
UltrasonicSensor sonar = new UltrasonicSensor(SensorPort.S1);
while(sonar.getDistance() > 50){
pilote.travelArc(20,10,true);
pilote.travelArc(-20,10,true);
}
}
}
It actually does nothing. I think it's coming from the immediatereturn. When I do a single
- Code: Select all
DifferentialPilot pilote = new DifferentialPilot(5.5, 17, Motor.A, Motor.B);
pilote.travelArc(20,10,true);
nothing happens. But, if I remove the "true" (immediatereturn), Motor are well going forward().
Is there a way to keep the immediatereturn or to perform this task (Finding an object) ? Have I done something wrong ?
Thanks for your help !
(And sorry for my horrible english !
