project Rambler from Intelligence Unleashed

Post your NXJ projects, project ideas, etc here!

Moderators: roger, 99jonathan, imaqine

project Rambler from Intelligence Unleashed

Postby masaguchi46 » Wed Jan 18, 2012 12:24 am

I am currently working on a project Rambler from the new book Intelligence Unleashed by Brian Bagnall.
Unfortunately there is something wrong with the code that won't let me compile.
The following line is not working.
Code: Select all
Navigator nav = new Navigator(p);


The whole program is this:
Code: Select all
import lejos.robotics.navigation.*;
import lejos.nxt.*;

public class Rambler {

   public static final int AREA_WIDTH = 200;
   public static final int AREA_LENGTH = 200;
     
    public static void main(String[] args) throws Exception {
       
        DifferentialPilot p = new DifferentialPilot(DifferentialPilot.WHEEL_SIZE_NXT2, 15.5, Motor.B, Motor.C);
        Navigator nav = new Navigator(p);
       
        // Repeatedly drive to random points:
        while(!Button.ESCAPE.isPressed()) {
           System.out.println("Target: ");
           double x_targ = Math.random() * AREA_WIDTH;
           double y_targ = Math.random() * AREA_LENGTH;
           System.out.println("X: " + (int)x_targ);
           System.out.println("Y: " + (int)y_targ);
           System.out.println("Press ENTER key");
           Button.ENTER.waitForPressAndRelease();
           
           nav.addWaypoint(new WayPoint(x_targ, y_targ));
           nav.addWaypoint(new WayPoint(0, 0, 0));
        }
    }
}


Thanks,
masaguchi46
New User
 
Posts: 3
Joined: Wed Jan 18, 2012 12:15 am

Re: project Rambler from Intelligence Unleashed

Postby masaguchi46 » Wed Jan 18, 2012 6:13 am

Actually worked by changing Navigator to NavPathController. Is this the same thing?
masaguchi46
New User
 
Posts: 3
Joined: Wed Jan 18, 2012 12:15 am

Re: project Rambler from Intelligence Unleashed

Postby TechnoX » Wed Jan 18, 2012 6:01 pm

I think lejos have changed the API and the book was released before the new lejos version is out.
You can either change your code, as you did here. But that may not work for everything, so I would suggest you to update your lejos installation to the snapshot if you are getting more errors with the examples in the book.

You can se this thread for more information about getting the latest lejos code!
viewtopic.php?f=7&t=2925

Happy coding! :D
TechnoX
Novice
 
Posts: 51
Joined: Tue May 03, 2011 5:57 pm
Location: Sweden

Re: project Rambler from Intelligence Unleashed

Postby masaguchi46 » Wed Jan 18, 2012 9:02 pm

Thank you so much. Everything worked!!
masaguchi46
New User
 
Posts: 3
Joined: Wed Jan 18, 2012 12:15 am

Re: project Rambler from Intelligence Unleashed

Postby hatakma » Sun Jan 29, 2012 12:15 pm

If instructions (for Windows only) are followed on OS X, the Rambler sample will be compiled OK and transferred to NXT brick,
but runtime Exception: 115 will occur!
Having just replaced 'bin' and 'lib' folders on 'lejos_nxt' folder (from 'snapshot' folder), but not 'build.xml' because it is for Windows.
The 'build.xml' for OS X has OS dependent stuff.
Do I have to upload the snapshot 'lejos_next_rom-bin' to NXT brick also, or is the same as on 'original' lejOS 0.9.0 build?

Having 0.9.0 NXT for OS X and also 0.9.0 beta ROM bin on NXT brick.

/Markku
hatakma
New User
 
Posts: 6
Joined: Sun Jan 29, 2012 11:07 am

Re: project Rambler from Intelligence Unleashed

Postby hatakma » Sun Jan 29, 2012 6:20 pm

Okay. One has to also update NXT brick to 0.9.1 version.

'Rambler' sample starts, but Navigator.addWaypoint(new Waypoint(x_targ, y_targ)) method
will not 'start motors'? Something's wrong. The new Navigator class does not work as it should?

Navigator.goTo(...) methods are although working...

/Markku
hatakma
New User
 
Posts: 6
Joined: Sun Jan 29, 2012 11:07 am

Re: project Rambler from Intelligence Unleashed

Postby hatakma » Sun Jan 29, 2012 7:30 pm

Now it works, almost!

One has to add a method call
nav.followPath();

to 'start the motors' i.e. navigation

nav.addWaypoint(new Waypoint(x_targ, y_targ));
nav.addWaypoint(new Waypoint(0, 0, 0));
nav.followPath();

But still it doesn't work correctly!
The car robot don't return to the origin, but returns to point (x_targ,0).
I'm expecting it returns using the same path to point (0,0)?

/Markku
hatakma
New User
 
Posts: 6
Joined: Sun Jan 29, 2012 11:07 am

Re: project Rambler from Intelligence Unleashed

Postby gloomyandy » Sun Jan 29, 2012 7:50 pm

Hi,
There is no need to post the same information on two threads. If anyone can help I'm sure they will see the thread no matter which section it is in. Please choose one section and just use that, I will then delete the other thread...

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3012
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK


Return to NXJ Projects

Who is online

Users browsing this forum: No registered users and 1 guest

more stuff