Hi,

I have problems to control a NXT with the Pilot. Following programm causes the 
robot to move forward until the right button is pressed, then it stops and 
starts rotating endlessly. After start of rotating is not possible to quit the 
program with the left button.

package nxj;

import lejos.nxt.*;
import lejos.navigation.*;

public class Main implements ButtonListener{

    private Pilot pilot;

    public static void main(String[] arg){
       Main m = new Main();
       m.doTask();
    }

    public void doTask(){
       pilot = new Pilot(5.6f, 15.5f, Motor.A, Motor.C, true);

       Button.RIGHT.addButtonListener(this);
       startAction();

       try {
          Button.LEFT.waitForPressAndRelease();
       } catch(Exception e){
       }
    } // doTask

    public void startAction() {
       pilot.forward();
    }

    public void buttonAction() {
       pilot.stop();
       pilot.rotate(60);
    }

    public void buttonPressed(Button arg0) {
    }

    public void buttonReleased(Button arg0) {
       buttonAction();
    }

} // Main

I recognized that everything is working as expected, when I substitute 
Thread.yield() with Thread.sleep(80) in the Pilot class.
I also tried several threadsafe variations of this programm with sychronized 
and 
wait() but it is always the same. Therefore, it is hard to believe that anyone 
uses this class in a productive way.

I also posted this problem in the forum, but got no response so far.

Any ideas what's wrong with my code?

Regards,
Jakob

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Lejos-discussion mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/lejos-discussion

Reply via email to