Pathfinder mapping

Post your NXJ projects, project ideas, etc here!

Moderators: 99jonathan, roger, imaqine

Pathfinder mapping

Postby hb.mortensen » Wed May 07, 2008 12:40 pm

Hello!

We're doing a NXT program using lejos making a robot pathfinder that can find the shortest road back after exploring the whole maze.
For finding the shortest path we where trying to store the roads the robot finds along its way in an ArrayList, but when we try to upload the program, it says and error concerning the arraylist...
Does lejos on the nxt not support arraylists even though it is posted in the API? Have u any ideas on how to solve this problem?
We thought about connecting the robot to at computer via bluetooth so the computer would manage and store the roads, but we're pretty new to java programming and using bluetooth seems kinda complicated, so if this solution is the preffered one, does anyone have a simple tutorial to use this...?

Should we switch to iCommand maybe? seems like easier access to utilization of bluetooth...? We just like the lejos tachonavigator...

Regards
Henrik
hb.mortensen
New User
 
Posts: 10
Joined: Wed Apr 02, 2008 11:26 am

Postby lawrie » Wed May 07, 2008 4:54 pm

What error do you get? Please post the failing code and the error.

ArrayList is supported by leJOS, but leJOS only supports Java source level 1.3, so generics are not supported. So you cannot use ArrayList<type>.
lawrie
leJOS Team Member
 
Posts: 929
Joined: Mon Feb 05, 2007 1:27 pm

Postby hb.mortensen » Tue Jun 10, 2008 7:20 am

It gives us the error message:
an error occurred: Method add(Ljava/lang/Object;)Z not found in java/util/ArrayList

We got a class named "roads"

And we want to store these road segments in an arraylist as the robots discovers them. Is this simply not possible in the present lejos version?

we're using the commands ex.:
ArrayList map = new ArrayList();
and map.add(road);

Is there maybe another more correct way to do this?
hb.mortensen
New User
 
Posts: 10
Joined: Wed Apr 02, 2008 11:26 am

Postby lawrie » Wed Jun 11, 2008 5:57 pm

What you are doing should work fine with leJOS. How are you compiling, linking and uploading your program, as you seem to be picking up the standard Java classes rather than classes.jar?

What command do you get the error from?

The add method in leJOS returns void rather than boolean. I will change this so the leJOS version is more standard. However if you compile and link correctly with classes.jar, your program should work fine.
lawrie
leJOS Team Member
 
Posts: 929
Joined: Mon Feb 05, 2007 1:27 pm


Return to NXJ Projects

Who is online

Users browsing this forum: Google [Bot] and 3 guests

cron
more stuff