Ask Your Question
1

Use an external library in rosjava

asked 2011-09-26 23:51:25 -0500

Alexandr Buyval gravatar image

I wrote a node (rosjava) that uses the library "lejos". Node compile without error, but when I run the node

rosrun rosjava_bootstrap run.py nxt_rosjava org.ros.nxt_rosjava.Listener

I get an error

Buildfile: /home/alex/lego-nxt-car-like/nxt_rosjava/dependencies.xml

get-dependencies:

BUILD SUCCESSFUL
Total time: 3 seconds
Executing command: ['java', '-classpath', u'/home/alex/lego-nxt-car-like/nxt_rosjava/target/org.ros.rosjava.nxt_rosjava-0.0.0.jar:/home/alex/.ros/rosjava/lib/org.ros.rosjava.test_ros-0.0.0.jar:/home/alex/.ros/rosjava/lib/org.ros.rosjava.roscpp-0.0.0.jar:/home/alex/.ros/rosjava/lib/org.ros.rosjava.topic_tools-0.0.0.jar:/opt/ros/diamondback/stacks/rosjava_core/apache_xmlrpc/target/org.ros.rosjava.apache-xmlrpc-3.1.3.jar:/opt/ros/diamondback/stacks/rosjava_core/rosjava_bootstrap/target/org.ros.rosjava.rosjava_bootstrap-0.0.0.jar:/home/alex/.ros/rosjava/lib/org.ros.rosjava.std_msgs-0.0.0.jar:/opt/ros/diamondback/stacks/rosjava_core/rosjava/target/org.ros.rosjava-0.0.0.jar:/home/alex/.ros/rosjava/lib/org.ros.rosjava.rosgraph_msgs-0.0.0.jar:/home/alex/.ros/rosjava/lib/org.ros.rosjava.geometry_msgs-0.0.0.jar:/opt/ros/diamondback/stacks/rosjava_core/apache_commons_util/target/org.ros.rosjava.ws-commons-util-1.0.2.jar:/home/alex/.m2/repository/com/google/guava/org.ros.rosjava.guava/r07/org.ros.rosjava.guava-r07.jar:/home/alex/.m2/repository/dnsjava/org.ros.rosjava.dnsjava/2.1.1/org.ros.rosjava.dnsjava-2.1.1.jar:/home/alex/.m2/repository/org/apache/commons/com.springsource.org.apache.commons.codec/1.3.0/com.springsource.org.apache.commons.codec-1.3.0.jar:/home/alex/.m2/repository/org/apache/commons/com.springsource.org.apache.commons.httpclient/3.1.0/com.springsource.org.apache.commons.httpclient-3.1.0.jar:/home/alex/.m2/repository/org/apache/commons/com.springsource.org.apache.commons.logging/1.1.1/com.springsource.org.apache.commons.logging-1.1.1.jar:/home/alex/.m2/repository/org/jboss/netty/netty/3.2.4.Final/netty-3.2.4.Final.jar', 'org.ros.RosRun', 'org.ros.nxt_rosjava.Listener']
Loading node class: org.ros.nxt_rosjava.Listener
Exception in thread "main" java.lang.NoClassDefFoundError: lejos/nxt/Motor
    at org.ros.nxt_rosjava.Listener.main(Listener.java:36)
    at org.ros.RosRun.main(RosRun.java:71)

I think that I need add "/home/alex/lejos_nxj/lib/pc/pccomm.jar" in dependencies.xml, but how to do it?

edit retag flag offensive close merge delete

Comments

I realize this is solved, but I wrote a quick tutorial for what worked for me. it may be of some use for someone else. http://coe.uncc.edu/~acharris/How_To_ROSJAVA/ROSJAVA_Tutorial.html
morrowsend gravatar image morrowsend  ( 2011-10-11 12:32:49 -0500 )edit

2 Answers

Sort by » oldest newest most voted
2

answered 2011-09-27 21:44:10 -0500

updated 2011-09-28 09:31:16 -0500

You need to add the path of the jar file in manifest.xml in the rosjava_pathelement tag. And you also need to add the path in ros.properties to the classpath and jarfileset properties. Take care to use the right delimiter (, vs :).

Edit: So my procedure to include external (i.e. non-ros) jar files now is:

  • Create a package, e.g., "external_jar", create subfolder, put jar-files there
  • Add a rosjava_pathelement tag with the relative path to each jar file to external_jar's manifest.xml (see other rosjava manifest.xml files for exact syntax)
  • Declare dependency on external_jar in manifest of the package where the jar-files are needed.
  • Rosmake your package
edit flag offensive delete link more

Comments

Hm, there is more to it, it seems. I'll update this tomorrow
Felix Endres gravatar image Felix Endres  ( 2011-09-28 04:23:00 -0500 )edit
Node runs!!! I add "<rosjava-pathelement location="/home/alex/lejos_nxj/lib/pc/pccomm.jar" />" in manifest.xml and run "rosmake nxt_rosjava". Thank you!
Alexandr Buyval gravatar image Alexandr Buyval  ( 2011-09-28 05:04:45 -0500 )edit
Great! With the above description you can use the relative location, which makes your package portable to other computers.
Felix Endres gravatar image Felix Endres  ( 2011-09-28 09:32:58 -0500 )edit
I'm doing something similar and having problems. Even when I add the <rosjava-pathelement location="/direct/library/path"> to my manifest.xml, my builds keep failing because it can't find the imports for the new library. This is a completely non-ROS library I'm adding so "depend" doesn't work.
morrowsend gravatar image morrowsend  ( 2011-10-05 06:15:17 -0500 )edit
I build project in Eclipse. Before build I add the path of the jar file in ros.properties to the ros.compile.classpath and ros.compile.jarfileset properties.If I launch "rosmake" then those properties erase and I need to add again.
Alexandr Buyval gravatar image Alexandr Buyval  ( 2011-10-06 06:39:39 -0500 )edit
Ok, now I got it to build. But have a running problem, which probably requires its own post. Thanks for the help!!!
morrowsend gravatar image morrowsend  ( 2011-10-07 04:43:48 -0500 )edit
0

answered 2012-01-01 03:17:07 -0500

Did you solve the problems with pccomm.jar?

I have just uploaded some examples in LeJOS project: https://lejos.svn.sourceforge.net/svnroot/lejos/trunk/ros/examples/">https://lejos.svn.sourceforge.net/svnroot/lejos/trunk/ros/examples/

Juan Antonio

edit flag offensive delete link more

Comments

Yes, I have solved the problem with pccomm.jar. Now I am writting ros package for connect NXT through LeJOS. http://code.google.com/p/lego-nxt-car-like/
Alexandr Buyval gravatar image Alexandr Buyval  ( 2012-02-01 20:59:47 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2011-09-26 23:51:25 -0500

Seen: 1,382 times

Last updated: Jan 01 '12