NavMapControl sample doesn't work

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

Moderators: 99jonathan, roger, imaqine

NavMapControl sample doesn't work

Postby nxtnewbie » Mon Jun 04, 2012 6:19 pm

Hello!
I want to use the sample NavMapControl on the PC which is in the direction below:
C:\Users\"Name of User"\Documents\LeJOS NXJ Samples\pcsamples\src\org\lejos\pcsample\navmapcontrol
while running on the NXT the sample RCNavMapper which is in the direction below:
C:\Users\"Name of User"\Documents\LeJOS NXJ Samples\samples\src\org\lejos\sample\rcnavmapper
There are two issues in the program:
Firstly, when I put an angle in the GUI box and press rotate, the rotation is not precise, although I have put the right dimensions for my NXT. Actually, the angle that the robot is rotated is the 2/3 of the angle that I put.
Secondly, when I put two integers to x and y GUI boxes and then press Go XY, nothing happens.
Note that the connection between the PC and the NXT works fine.
Please help me!
Thanks in advance for your assistance.
nxtnewbie
New User
 
Posts: 11
Joined: Sat Apr 14, 2012 7:31 pm

Re: NavMapControl sample doesn't work

Postby matthias » Wed Jun 06, 2012 6:17 am

The NXT is not a precision robot.
matthias
New User
 
Posts: 20
Joined: Thu Mar 22, 2012 11:44 am

Re: NavMapControl sample doesn't work

Postby kirkpthompson » Wed Jun 06, 2012 1:30 pm

Hi.
Firstly, when I put an angle in the GUI box and press rotate, the rotation is not precise, although I have put the right dimensions for my NXT. Actually, the angle that the robot is rotated is the 2/3 of the angle that I put.

This could be due to wheel slippage (a common odometry problem). Can you observe any? Have you tried to slow down the robot to see if you get better accuracy?

Best,
-K
Leg Godt!
User avatar
kirkpthompson
leJOS Team Member
 
Posts: 304
Joined: Wed Dec 05, 2007 1:27 am
Location: New Mexico, USA

Re: NavMapControl sample doesn't work

Postby kirkpthompson » Wed Jun 06, 2012 1:39 pm

Also, try to do some searching in the forum. This thread may be useful: http://lejos.sourceforge.net/forum/viewtopic.php?f=7&t=3186&p=16263&hilit=Differential#p15811

Best,
-K
Leg Godt!
User avatar
kirkpthompson
leJOS Team Member
 
Posts: 304
Joined: Wed Dec 05, 2007 1:27 am
Location: New Mexico, USA

Re: NavMapControl sample doesn't work

Postby nxtnewbie » Fri Jun 08, 2012 12:02 am

kirkpthompson wrote:Hi.
This could be due to wheel slippage (a common odometry problem). Can you observe any? Have you tried to slow down the robot to see if you get better accuracy?


There is no slippage neither on the floor nor my desk. The angle is the same despite the speed and is exactly 2/3 of the original. For example, if you put 135 in the rotate angle box, the robot rotates 90 degrees (2*135/3 = 90). I attach below the class that executes when you push each different button in the GUI. Where can I find the code "behind" the methods GOTO and ROTATE? The others (STOP, SETPOSE, TRAVEL and connect) work fine.

Code: Select all
public void actionPerformed(ActionEvent e)
   {      
      if (e.getSource() == stopButton) com.sendData(NavCommand.STOP.ordinal(),
            0,0,0,true);
      else if(e.getSource() == goToButton){
         readXY();
         com.sendData(NavCommand.GOTO.ordinal(),30*_x,30*_y,0,true);
         //com.sendData(Navigator.goTo(_x, _y));
         
      }
      else if(e.getSource() == setPoseButton) {
         readRXY();
         readHeading();
         com.sendData( NavCommand.SETPOSE.ordinal(),30*_Rx,30*_Ry,_heading,true);
      }
      else if (e.getSource() == rotateButton)
      {

         readAngle();
         com.sendData(NavCommand.ROTATE.ordinal(),_angle,0,0,true);
      }
      else if (e.getSource() == travelButton){
         readDistance();
         com.sendData(NavCommand.TRAVEL.ordinal(),30*_distance,0,0,true);
      }
      else if(e.getSource()== connectButton)
      {
         String name = nameField.getText();
         System.out.println(" Connect Button "+name);             
         boolean ok = com.connect(name, address);
         if(!ok)System.out.println("No connection ");
      }
   }
nxtnewbie
New User
 
Posts: 11
Joined: Sat Apr 14, 2012 7:31 pm

Re: NavMapControl sample doesn't work

Postby kirkpthompson » Fri Jun 08, 2012 3:46 am

Hi.

It appears to be in org.lejos.sample.rcnavmapper:
Code: Select all
public  void execute(int code, float v0, float v1, float v2, boolean immediate)
    {
         NavCommand command = NavCommand.values()[code];  // convert int to enum     
         LCD.clear();
         LCD.drawString(command.toString(),0,0);
         Sound.playTone(800 + 100 * code, 200);;
         if(command == NavCommand.STOP)
         {
            pilot.stop();
            nav.stop();
            report(pp.getPose());
         }
         else if(command == NavCommand.GOTO )
         {
            nav.addWaypoint(new Waypoint(v0, v1));
            _report = true;
            detector.enableDetection(true);
         }
         else if(command == NavCommand.TRAVEL)
         {
            float distance = v0;
            LCD.drawString("D " + Math.round(distance), 0, 2);
            pilot.travel(distance, true);
            _report = true;
            detector.enableDetection(true);
         }else if (command == NavCommand.ROTATE)
      {
         float angle = v0;
         pilot.rotate(angle,true);
         _report = true;
         LCD.drawString("A " + Math.round(angle), 0, 2);
      } else if (command == NavCommand.SETPOSE)
      {
         pp.setPose(new Pose(v0, v1, v2));
         report(pp.getPose());
      }
   }


The source is installed with LeJOS on your machine or you can browse the SVN repos: http://lejos.svn.sourceforge.net/viewvc/lejos/trunk/samples/src/org/lejos/sample/rcnavmapper/RCNavMapper.java?view=log

-K
Leg Godt!
User avatar
kirkpthompson
leJOS Team Member
 
Posts: 304
Joined: Wed Dec 05, 2007 1:27 am
Location: New Mexico, USA

Re: NavMapControl sample doesn't work

Postby nxtnewbie » Thu Jun 21, 2012 3:03 am

kirkpthompson wrote:Hi.

It appears to be in org.lejos.sample.rcnavmapper:
Code: Select all
public  void execute(int code, float v0, float v1, float v2, boolean immediate)
    {
         NavCommand command = NavCommand.values()[code];  // convert int to enum     
         LCD.clear();
         LCD.drawString(command.toString(),0,0);
         Sound.playTone(800 + 100 * code, 200);;
         if(command == NavCommand.STOP)
         {
            pilot.stop();
            nav.stop();
            report(pp.getPose());
         }
         else if(command == NavCommand.GOTO )
         {
            nav.addWaypoint(new Waypoint(v0, v1));
            _report = true;
            detector.enableDetection(true);
         }
         else if(command == NavCommand.TRAVEL)
         {
            float distance = v0;
            LCD.drawString("D " + Math.round(distance), 0, 2);
            pilot.travel(distance, true);
            _report = true;
            detector.enableDetection(true);
         }else if (command == NavCommand.ROTATE)
      {
         float angle = v0;
         pilot.rotate(angle,true);
         _report = true;
         LCD.drawString("A " + Math.round(angle), 0, 2);
      } else if (command == NavCommand.SETPOSE)
      {
         pp.setPose(new Pose(v0, v1, v2));
         report(pp.getPose());
      }
   }


The source is installed with LeJOS on your machine or you can browse the SVN repos: http://lejos.svn.sourceforge.net/viewvc/lejos/trunk/samples/src/org/lejos/sample/rcnavmapper/RCNavMapper.java?view=log

-K


Thanks, sorry for not replying earlier but I was abroad. I have fixed the rotation by changing the track width (note that is far from the real one).
As for the go to command I have made several tries, but in all cases the result is the same and not the desired one. I will explain what I mean and at the end I will conclude 2 of my tries. When I set the initial robot pose to x=0, y=0 and heading=0, and I tell it to go to x=1 and y=0, it goes like a charm. The problem is that when I press again the goto button without changing anything (with x and y still being 1 and 0 respectively), the robot repeats its previous move (it moves forward 1 unit (in my case meters)). Thus, the robot, each time it stops, it sets its position to be the origin. I need a way for the robot to understand that it's already in x=1 and y=0 and doesn't need to move. Could you please help with that? Thanks.
Here are my tries:

//Try No1:
else if(command == NavCommand.GOTO )
{
nav.addWaypoint(new Waypoint(v0, v1));
nav.followPath();
_report = true;
detector.enableDetection(true);
}
//Try No2:
else if(command == NavCommand.GOTO )
{
nav.goTo(v0, v1);
_report = true;
detector.enableDetection(true);
}
nxtnewbie
New User
 
Posts: 11
Joined: Sat Apr 14, 2012 7:31 pm

Re: NavMapControl sample doesn't work

Postby nxtnewbie » Thu Jun 21, 2012 7:26 pm

Never mind, I've fixed it, thanks for all!
nxtnewbie
New User
 
Posts: 11
Joined: Sat Apr 14, 2012 7:31 pm

Re: NavMapControl sample doesn't work

Postby kirkpthompson » Thu Jun 21, 2012 8:00 pm

And, what was the solution so that others may know and learn?

-K
Leg Godt!
User avatar
kirkpthompson
leJOS Team Member
 
Posts: 304
Joined: Wed Dec 05, 2007 1:27 am
Location: New Mexico, USA

Re: NavMapControl sample doesn't work

Postby nxtnewbie » Tue Jun 26, 2012 10:03 pm

kirkpthompson wrote:And, what was the solution so that others may know and learn?


I had done a mistake with the robot original pose, the code works fine with both of the tries I have mentioned.
nxtnewbie
New User
 
Posts: 11
Joined: Sat Apr 14, 2012 7:31 pm


Return to NXJ Software

Who is online

Users browsing this forum: No registered users and 0 guests

more stuff