Ask Your Question
0

ROSJAVA and External Libraries (again)

asked 2012-01-27 02:33:24 -0500

Markus Eich gravatar image

updated 2012-01-27 02:34:45 -0500

Dear all,

I try to include an external library to the example of rosjava_tutorial_pubsub_Listener.

I modified the code as follows:

 package org.ros.tutorials.pubsub;
 import org.apache.commons.logging.Log;
 import org.ros.message.MessageListener;
 import org.ros.namespace.GraphName;
 import org.ros.node.Node;
 import org.ros.node.NodeMain;
 import org.ros.node.topic.Subscriber;
 import cylinder_reasoner.*;

 /**
 * This is a simple rosjava {@link Subscriber} {@link Node}. It assumes an
 * external roscore is already running.
 * 
 * @author damonkohler@google.com (Damon Kohler)
 */
 public class Listener implements NodeMain {

  @Override
  public GraphName getDefaultNodeName() {
  return new GraphName("rosjava_tutorial_pubsub/listener");
  }

   @Override
   public void onStart(Node node) {
   final Log log = node.getLog();
   CylinderReasoner reasoner=new CylinderReasoner();
   reasoner.doReasoning("//home//eich//Cylinders.txt");

   Subscriber<org.ros.message.std_msgs.String> subscriber =
     node.newSubscriber("chatter", "std_msgs/String");
    subscriber.addMessageListener(new MessageListener<org.ros.message.std_msgs.String>()   
   {
    @Override
    public void onNewMessage(org.ros.message.std_msgs.String message) {
     log.info("I heard: \"" + message.data + "\"");
  }
});
}`

Than I added the following line to the manifest.txt

<rosjava-pathelement location="/home/eich/Test.jar" />

Test Test.jar contains the Package cylinder_reasoner.CylinderReasoner.

Problem is I cannot compile. The error is that

Listener.java:25: package cylinder_reasoner does not exist

Do I have to set the jar file somewhere else as well? Or only in the manifest. After calling rosmake, the .classpath is updated correctly, but it cannot find the package.

Do you have any ideas?

Thank you

edit retag flag offensive close merge delete

4 Answers

Sort by ยป oldest newest most voted
0

answered 2012-02-01 00:05:15 -0500

Markus Eich gravatar image

I solved the problem by adding the needed jars files to the ros.properties. This seems to work. The problem is I have to add them every time I call rosmake.

edit flag offensive delete link more

Comments

Sounds like a bug. I've filed this issue: http://code.google.com/p/rosjava/issues/detail?id=85
damonkohler gravatar image damonkohler  ( 2012-02-02 02:01:30 -0500 )edit

I also tried to use relative path (i.e. the jars are in the root directory of the rosjava project). They are not added to ros.properties either.

Markus Eich gravatar image Markus Eich  ( 2012-02-15 03:47:46 -0500 )edit
0

answered 2012-01-29 22:42:17 -0500

Markus Eich gravatar image

updated 2012-01-29 22:43:13 -0500

Thanks for the answer. I tried both eclipse and ant. Ant gives a compile error

Compiling 1 source file to /home/eich/dev/rosjava_core/rosjava_tutorial_pubsub/target/classes
[javac] Listener.java:25: package cylinder_reasoner does not exist
[javac] import cylinder_reasoner.*;

Although I set up the path to my Test.jar in the manifest. I run make in the project folder and get a compile error.

When I try to run the project in Eclipse (which I would prefere) I get another error Usage: rosrun rosjava_bootstrap run.py org.foo.MyNode [args] __name:=<node name="">

How can I setup Eclipse to run the node? I tried to enter rosjava_tutorial_pubsub org.ros.tutorials.pubsub.Listener in the arguments list. Than I get another error

Loading node class: rosjava_tutorial_pubsub
Exception in thread "main" org.ros.exception.RosRuntimeException: Unable to locate node: rosjava_tutorial_pubsub
at org.ros.RosRun.main(RosRun.java:64)
Caused by: java.lang.ClassNotFoundException: rosjava_tutorial_pubsub
edit flag offensive delete link more
0

answered 2012-01-29 22:49:14 -0500

Markus Eich gravatar image

I just realized that my Test.jar is NOT included in the ros.properties after calling make. Shouldn't it be there after calling make? Where is the information stored where <rosjava-pathelement location="/home/eich/Test.jar"/> is pointing to?

Cheers,

Markus

edit flag offensive delete link more
0

answered 2012-01-27 03:40:49 -0500

damonkohler gravatar image

How are you compiling? Eclipse? Ant?

After modifying the manifest.xml, you'll need to run make in the package to update the ant scripts. After you've run make, you can then skip running make in the future and just compile with either ant or Eclipse. Skipping make is faster.

edit flag offensive delete link more

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: 2012-01-27 02:33:24 -0500

Seen: 1,090 times

Last updated: Feb 01 '12