Painting square to ground

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

Moderators: 99jonathan, roger, imaqine

Painting square to ground

Postby NadirHajiyev » Mon Jul 16, 2012 10:04 am

Hello.
I tried to paint the ground by using my Lego, so i wrote a code for moving (straight 2m and turn left) for times. Here is my code.
Code: Select all
import lejos.nxt.Motor;
import lejos.robotics.RegulatedMotor;
import lejos.robotics.navigation.DifferentialPilot;
import lejos.robotics.navigation.MoveController;
import lejos.util.PilotProps;

public class SquareMove{
   static PilotProps pp = new PilotProps();
   static float wheelDiameter = Float.parseFloat(pp.getProperty(PilotProps.KEY_WHEELDIAMETER, "4.32"));
   static float trackWidth = Float.parseFloat(pp.getProperty(PilotProps.KEY_TRACKWIDTH, "16.35"));
   static RegulatedMotor leftMotor = PilotProps.getMotor(pp.getProperty(PilotProps.KEY_LEFTMOTOR, "A"));
   static RegulatedMotor rightMotor = PilotProps.getMotor(pp.getProperty(PilotProps.KEY_RIGHTMOTOR, "b"));
   static boolean reverse = Boolean.parseBoolean(pp.getProperty(PilotProps.KEY_REVERSE,"false"));
   
   public static void main(String[] args){
      
      setSpeed(500);
      for(int i=0;i<4;i++){
         travelForward(2);
         rotateLeft(90);
      }
   }

   private static void rotateLeft(int angle) {
      // TODO Auto-generated method stub
      DifferentialPilot dp = new DifferentialPilot(wheelDiameter, trackWidth, leftMotor, rightMotor, reverse);
      dp.rotate(90);
   }

   private static void travelForward(int distance) {
      // TODO Auto-generated method stub
      ((MoveController) Motor.A).travel(distance);
      ((MoveController) Motor.B).travel(distance);
   }

   private static void setSpeed(int speed) {
      // TODO Auto-generated method stub
      Motor.A.setSpeed(speed);
      Motor.B.setSpeed(speed);
   }
   
}

But when I run it I got
Exception 26
at: 97(3)
at: 95(13)

I do not have any idea to debug this code.
Please help me.
Thanks.
NadirHajiyev
New User
 
Posts: 20
Joined: Thu Jul 05, 2012 10:25 am

Re: Painting square to ground

Postby skoehler » Mon Jul 16, 2012 11:13 am

Use the "-v" switch of nxj or nxjlink, or use the -od switch to generate a *.nxd file and then use the nxjdebugtool to translate the numbers on the NXT's screen into class and method names.
http://lejos.sourceforge.net/nxt/nxj/tutorial/ErrorHandlingAndDebugging/ErrorHandling_and_debugging.htm#1
skoehler
leJOS Team Member
 
Posts: 1418
Joined: Thu Oct 30, 2008 4:54 pm


Return to NXJ Software

Who is online

Users browsing this forum: No registered users and 3 guests

more stuff