Motor.A.isRotating()?

This is where you talk about the NXJ software itself, installation issues, and programming talk.

Moderators: 99jonathan, roger, imaqine

Motor.A.isRotating()?

Postby Damian » Thu May 22, 2014 11:05 am

On http://www.lejos.org/p_technologies/nxt ... Motor.html

There is an example code

Example:

Motor.A.setSpeed(720);// 2 RPM
Motor.C.setSpeed(720);
Motor.A.forward();
Motor.C.forward();
Thread.sleep (1000);
Motor.A.stop();
Motor.C.stop();
Motor.A.regulateSpeed(true);
Motor.A.rotateTo( 360);
Motor.A.rotate(-720,true);
while(Motor.A.isRotating();
int angle = Motor.A.getTachoCount(); // should be -360

When I try this I get an error isRotating() is undefined, other than the while paranthesis. When I searched a little more I found out here
http://www.lejos.org/nxt/icommand/api/i ... Motor.html isRotating() is not yet implemented and we should use isMoving() instead, so is it implemented or not implemented, if implemented how can I use it? Also is isMoving() going to give me the same result as rotating? How can I use it?

Code: Select all
               
         while(!Button.ESCAPE.isDown())
           {
            Motor.A.rotateTo( 40);
            while(Motor.A.isMoving())
            {
             value = sonic.getDistance();
             LCD.clear();
             LCD.drawString("Distance: ", 0, 2);
             LCD.drawInt(value, 0, 3);
             LCD.refresh();
             Thread.sleep(100);   
            }
            Thread.sleep(100);   
           
            Motor.A.rotateTo( -40);
            while(Motor.A.isMoving())
             {
              value = sonic.getDistance();
              LCD.clear();
              LCD.drawString("Distance: ", 0, 2);
              LCD.drawInt(value, 0, 3);
              LCD.refresh();
              Thread.sleep(100);   
             }
              Thread.sleep(100);   
           }


Would the code above me give instant distances while the Ultrasonic sensor is rotating left and right? I will try in a bit and see if it works.
Damian
New User
 
Posts: 14
Joined: Sat Apr 12, 2014 8:27 am

Return to NXJ Software

Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 2 guests

more stuff