ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

how to add external jars to a class in rosjava hydro [closed]

asked 2014-01-19 01:17:06 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

I am trying to modify the Listener.java class in rosjava_tutorial_pubsub to accept a word from a publisher in python and then pass this word to a classifier which is an external jar I want to add to my listener.java class. This is the modified code of the Listener.java:

package org.ros.rosjava_tutorial_pubsub;

import org.apache.commons.logging.Log;

import org.ros.message.MessageListener;

import org.ros.namespace.GraphName;

import org.ros.node.AbstractNodeMain;

import org.ros.node.ConnectedNode;

import org.ros.node.NodeMain;

import org.ros.node.topic.Subscriber;

public class Listener extends AbstractNodeMain {

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

@Override public void onStart(ConnectedNode connectedNode) { final Log log = connectedNode.getLog();

***final edu.uic.cs.nlp.ros.da.DaClassifier daClassifer = DaClassifier.getInstance();***

Subscriber<std_msgs.String> subscriber =        
connectedNode.newSubscriber("chatter", std_msgs.String._TYPE);
subscriber.addMessageListener(new MessageListener<std_msgs.String>() {
  @Override
  public void onNewMessage(std_msgs.String message) {

  ***java.lang.String da = daClassifer.classify(message.getData());

  log.info("output of the classifier: \"" + da + "\"");***
  }
});

} }

Where do I add the classifier's jar as a dependency? I put the jar in the build/install/rosjava_tutorial_pubsub/lib along with the rest of the jars of the package. I also added the following line to my build.gradle:

compile fileTree(dir: 'build/install/rosjava_tutorial_pubsub/lib', include: 'lin.jar')

Is this enough in ros hydro or do i need to make changes in my package.xml as well?

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by tfoote
close date 2016-08-14 01:56:43.611898

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-01-20 18:27:55 -0500

uzair gravatar image

updated 2014-01-20 18:29:53 -0500

We dont need to make any changes in the package.xml. That method was for the older versions. For ROSJAVA hydro, we just have to add "compile files('lib/myjar.jar')" (without the "") in the dependencies in build.gradle of the project. lib is just a sub directory in my package where i put my external jars.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2014-01-19 01:17:06 -0500

Seen: 291 times

Last updated: Jan 20 '14