Problems with LeJOS 0.8.5 and NXTCam

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

Moderators: 99jonathan, roger, imaqine

Problems with LeJOS 0.8.5 and NXTCam

Postby Tompolth » Mon Sep 28, 2009 9:58 pm

Hi all,

Today I'd updated my NXT firmware from Lejos 0.8 to 0.85. Well, since I did all I got problems.

First, the ultrasonic sensor did not respond. I could see in the forum they had a problem with the I2C port number 4, which did not respond with ultrasonic sensor. I changed the sensor of position and fixed


The next problem I've encountered and I have no solution is that the NXTCam camera does not respond well . The camera is connected to port 1, I tried to connect on different ports but still no answer.

I tried the following code to see the answer but always returns a value of 78:


Code: Select all
import lejos.nxt.Button;
import lejos.nxt.LCD;
import lejos.nxt.SensorPort;
import lejos.nxt.Sound;
import lejos.nxt.addon.NXTCam;

public class Test {

   private static NXTCam camara;

   /**
    * @param args
    */
   public static void main(String[] args) {

      camara = new NXTCam(SensorPort.S1);
      camara.setTrackingMode(NXTCam.OBJECT_TRACKING);
      camara.sortBy(NXTCam.SIZE);

      while (!Button.ESCAPE.isPressed()) {

         if (camara.getNumberOfObjects() > 0) {
            LCD.drawString("          " +  camara.getNumberOfObjects(), 1, 1);
         } else {
            LCD.drawString("NOTHING", 1, 1);
         }

      }

   }
}



Of course in the previous version of NXJ the code works well, even with more complex programs. The problem is that I intended to reinstall the older version and does not seem possible for the plugin for eclipse, once updated, can not return to the previous version.


What is the problem so that the camera does not respond? Is it a bug?

I need urgent help, my final thesis project depends on this.

Thanks
Software Engineer
Tompolth
New User
 
Posts: 19
Joined: Sat Aug 30, 2008 6:29 pm

Postby gloomyandy » Mon Sep 28, 2009 10:23 pm

Hi,
I don't have access to an NXTCam so I can't test it. I suspect that the same bug that causes problems on port 4 may be causing this problem. You could try applying the fix and rebuilding your classes.jar. The changes are here:
http://lejos.svn.sourceforge.net/viewvc/lejos/trunk/classes/lejos/nxt/SensorPort.java?r1=3417&r2=3423

Once built I'm not sure what you will have to do to get the Eclipse plug in to use the new jar file (I don't use Eclipse). You may want to test the changes using the command line tools to build and run your test code. To do this you will have to replace the classes.jar in your leJOS lib directory.

Andy

PS You should probably back things up before you start. But then you have probably learned that by now... ;-)
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4001
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Problems with LeJOS 0.8.5 and NXTCam

Postby Shawn » Mon Sep 28, 2009 10:42 pm

Tompolth wrote:
What is the problem so that the camera does not respond? Is it a bug?

I need urgent help, my final thesis project depends on this.

Thanks


If all else fails, you can probably do another install of Eclipse and use the .8 version. Like Andy says though, it's pretty easy to rebuild and swap the classes jar.
User avatar
Shawn
Advanced Member
 
Posts: 723
Joined: Wed Sep 12, 2007 4:59 am
Location: Tokyo

Postby Tompolth » Tue Sep 29, 2009 6:52 am

Thanks for your quick response. I'll try
Software Engineer
Tompolth
New User
 
Posts: 19
Joined: Sat Aug 30, 2008 6:29 pm

Postby Tompolth » Wed Sep 30, 2009 3:47 pm

Andy, I updated and rebuilt the file classes.jar and the problem of failure of the port number 4 with the ultrasonic sensor is corrected, however the NXTCam keeps failing.


The getNumberOfObjects() function always returns the value 78 and the getObjectColor(0) function returns the value 67, regardless of the port where the camera is connected.


Could you try the little program I posted to see if it's a bug or maybe my mistake.

Thanks
Software Engineer
Tompolth
New User
 
Posts: 19
Joined: Sat Aug 30, 2008 6:29 pm

Postby gloomyandy » Wed Sep 30, 2009 4:29 pm

Hi,
Sorry I don't have an NXTCam so I can't test this for you. I suggest that you try the following...

1. Add calls to getVersion(), getProductId() and getSensorType() into your test code. This will check to see if the i2c code is talking to the device.

2. Have you tried the device with an older version of leJOS since you started getting the errors? If not can you do that (you can build your test program using the leJOS command line tools you don't need a working Eclipse to do it). That way we can establish that the fault is with the new version of leJOS.

3. Does it still work if you plug it into a PC?

4. Is there any way to reset the device? If so it is probably worth trying that.

5. You may want to add some delays between calls to the device. Newer versions of leJOS are faster than older ones. It may be that the device is not able to handle requests very close together.

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

Postby lawrie » Wed Sep 30, 2009 6:18 pm

I don't know why a value of 78 is returned for the number of objects - the same happens for me.

However, don't you need to make a call to enableTracking(true)? If I add that, I get sensible results.

Did this program work without a call to enableTracking or sendCommand('E'), at the 0.8 release? There do not seem to be any changes to the NXTCam class since the 0.8 release and I do not know of any other change to leJOS which is likely to affect this.

If you need to use it, the 0.8 Eclipse plugin should be available at http://lejos.sourceforge.net/tools/ecli ... in/nxj080/. If you try it, let me know if it works.
lawrie
leJOS Team Member
 
Posts: 921
Joined: Mon Feb 05, 2007 1:27 pm

Postby Tompolth » Wed Sep 30, 2009 8:16 pm

Great, Lawrie. The problem was the lack of calling to enableTracking() function. However I don't undertand, before I'd never used and worked perfectly in version 0.8. :?:
Well, now I may continue with my project.

Thank you very much.
Software Engineer
Tompolth
New User
 
Posts: 19
Joined: Sat Aug 30, 2008 6:29 pm

Postby Tompolth » Wed Sep 30, 2009 8:29 pm

Sooorry :(
It was my mistake, I confused sendCommand Function ( 'E') with the function setTrackingMode (NXTCam.OBJECT_TRACKING). I always used the first function but recently I discovered the second and confused both.

I'm sorry if I caused trouble
Software Engineer
Tompolth
New User
 
Posts: 19
Joined: Sat Aug 30, 2008 6:29 pm


Return to NXJ Software

Who is online

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

more stuff