Problems loading through a server

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

Moderators: roger, 99jonathan, imaqine

Problems loading through a server

Postby pu2pe » Mon Oct 29, 2012 1:19 am

Hi there!

I'm new to leJOS community. Installed last version 0.9.1 in Windows 7, 32 bits, I've been able to run both samples and pcsamples, from USB and BT in my NXT (with last firmware 1.3) and last Phantom driver from Lego Mindstorms.

First of all, fantastic work you've done!! I'm trully impressed with what I've found.

Now, my question. I've done a Java Project where I connect to the NXT through NXTConnector and NXTCommandConnector.getSingletonOpen() and I can use all the sensors and the motors.

But when I wrap this project in a Glassfish server and run it, it turns that I can only get system values like getBatteryLevel() by adding jfantom.dll to c:\Windows\System32, and when I try to read sensor values, just by setting the SensorPort number I get an exception:

Code: Select all
UltrasonicSensor distanceSensor = new UltrasonicSensor(SensorPort.S3);

java.lang.UnsatisfiedLinkError: lejos.nxt.SensorPort.setPowerTypeById(II)V
   at lejos.nxt.SensorPort.setPowerTypeById(Native Method)
   at lejos.nxt.SensorPort.setPowerType(SensorPort.java:1063)
   at lejos.nxt.SensorPort.setType(SensorPort.java:973)
   at lejos.nxt.SensorPort.reset(SensorPort.java:822)
   at lejos.nxt.SensorPort.<init>(SensorPort.java:804)
   at lejos.nxt.SensorPort.<clinit>(SensorPort.java:39)


or if I try to access to the motors I get a similar one:

Code: Select all
DifferentialPilot pilot = new DifferentialPilot(wheelDiameter, wheelDistance, leftMotor, rightMotor);

java.lang.UnsatisfiedLinkError: lejos.nxt.Battery.getBatteryStatus()I
   at lejos.nxt.Battery.getBatteryStatus(Native Method)
   at lejos.nxt.Battery.getVoltageMilliVolt(Battery.java:34)
   at lejos.nxt.Battery.getVoltage(Battery.java:49)
   at lejos.nxt.NXTRegulatedMotor.getMaxSpeed(NXTRegulatedMotor.java:805)
   at lejos.robotics.navigation.DifferentialPilot.getMaxTravelSpeed(DifferentialPilot.java:273)
   at lejos.robotics.navigation.DifferentialPilot.<init>(DifferentialPilot.java:164)
   at lejos.robotics.navigation.DifferentialPilot.<init>(DifferentialPilot.java:109)
   at lejos.robotics.navigation.DifferentialPilot.<init>(DifferentialPilot.java:84)


So I think I've also to load the native library:

Code: Select all
System.loadLibrary("jfantom");


and put it in the glassfish lib folder, but nothing of this has worked out.

I've even checked the dll with Dependency Walker, and I'm only missing Nispylog.dll.

What am I doing wrong?? Can you help me??

Thank you in advance!

Jose
pu2pe
New User
 
Posts: 5
Joined: Sun Oct 28, 2012 8:06 pm

Re: Problems loading through a server

Postby gloomyandy » Mon Oct 29, 2012 8:48 am

That looks like you have loaded the leJOS classes.jar into your glassfish environment. classes.jar should only be used by programs that run on the nxt. You need to be loading pccomm.jar for pc based programs.
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3012
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Problems loading through a server

Postby pu2pe » Mon Oct 29, 2012 9:05 am

Indeed I added classes.jar into the environment. I'll try to remove it later and see what happens...

Thanks!
Jose
pu2pe
New User
 
Posts: 5
Joined: Sun Oct 28, 2012 8:06 pm

Re: Problems loading through a server

Postby pu2pe » Mon Oct 29, 2012 3:34 pm

It works!! gloomyandy, you're the man!!

Now sensors and motors work through http requests...!

Thank you very much, again, you've saved my day :D
Jose
pu2pe
New User
 
Posts: 5
Joined: Sun Oct 28, 2012 8:06 pm

Re: Problems loading through a server

Postby gloomyandy » Mon Oct 29, 2012 4:39 pm

Great news glad you got it all working... Don't forget to post a link so we can all see what you have been doing!
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3012
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Problems loading through a server

Postby pu2pe » Tue Oct 30, 2012 5:23 pm

For now I've got it working as a proof of concept.

For that I've done a minimum interface with JavaFX. I ask for the battery level through RESTful services and refresh the indicator of a cool control taken from the JFXtras project (http://jfxtras.org).

In the server side, with a Glassfish as the application server, the request goes to the NXT by bluetooth, gets the value and returns it back to the client.

Here it's a pic of this preliminary version, already working:

Image

I intend to post about it, I let you know when I've done it.

Best regards!
Jose
pu2pe
New User
 
Posts: 5
Joined: Sun Oct 28, 2012 8:06 pm

Re: Problems loading through a server

Postby pu2pe » Thu Nov 29, 2012 8:45 pm

Hi, finally I could blog about the first part of my little project:

http://jperedadnr.blogspot.com.es/2012/11/nxtlegofx-javafx-based-application-to.html

Hope you like it.

Next, I'll try to make a few JavaFX based blocks to remotely read sensors and control servos from the NXT.

Jose
pu2pe
New User
 
Posts: 5
Joined: Sun Oct 28, 2012 8:06 pm


Return to NXJ Software

Who is online

Users browsing this forum: Google [Bot] and 1 guest

more stuff