Robotics StackExchange | Archived questions

listener rosjava

I am trying to build a listener in rosjava. I used the code found at the rosjava core snapshot documentation and changed the GraphName() to GraphNmae.of(). I also added these lines to the code:

package com.github.rosjava.dude.Listener;(The name of my project is dude as it was given in the tutorial)

import org.ros.rosjavatutorialpubsub;

When I build this using catkin_make , I get two errors. THe errors and the code is given below. Can somebody please help me fix this. THanks a ton.

1st error:

/home/uahmed9/rosjava/src/rosjavafoo/dude/src/main/java/com/github/rosjava/dude/Listener.java:2: cannot find symbol symbol : class rosjavatutorialpubsub location: package org.ros import org.ros.rosjavatutorial_pubsub;

The dot between ros and rosjava in the import statement is creating error.

2nd error:

/home/uahmed9/rosjava/src/rosjavafoo/dude/src/main/java/com/github/rosjava/dude/Listener.java:21: cannot find symbol symbol : class of location: class org.ros.namespace.GraphName return new GraphName.of("rosjavatutorial_pubsub/listener");

The dot between GraphName and of in the import statement is creating error. The Code:

package com.github.rosjava.dude.Listener;

import org.ros.rosjavatutorialpubsub;

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 new GraphName.of("rosjava_tutorial_pubsub/listener");

}

@Override

public void onStart(ConnectedNode connectedNode) {

final Log log = connectedNode.getLog();

Subscriber<std_msgs.String> subscriber = connectedNode.newSubscriber("chatter", 

stdmsgs.String.TYPE);

subscriber.addMessageListener(new MessageListener<std_msgs.String>() {

  @Override

  public void onNewMessage(std_msgs.String message) {

    log.info("I heard: \"" + message.getData() + "\"");

  }

});

}

}

Asked by uzair on 2013-12-27 17:23:11 UTC

Comments

http://answers.ros.org/question/113436/rosjava-listener/ Duplicate

Asked by tfoote on 2013-12-27 20:21:57 UTC

u closed all the questions? can you reopen one of the duplicate questions? i dont know how it got posted so many times.

Asked by uzair on 2013-12-28 10:23:00 UTC

No I closed all duplicates except the one I linked to.

Asked by tfoote on 2013-12-28 11:44:50 UTC

oh..thanks!

Asked by uzair on 2013-12-28 12:04:54 UTC

Answers