I am trying to build a rosjava listener. I am getting the following errors even after making a few changes as given on the forums. I have provided the details. Please help me. [closed]
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.rosjava_tutorial_pubsub;
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/rosjava_foo/dude/src/main/java/com/github/rosjava/dude/Listener.java:2: cannot find symbol symbol : class rosjava_tutorial_pubsub location: package org.ros import org.ros.rosjava_tutorial_pubsub;
The dot between ros and rosjava in the import statement is creating error.
2nd error:
/home/uahmed9/rosjava/src/rosjava_foo/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("rosjava_tutorial_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.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 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",
std_msgs.String._TYPE);
subscriber.addMessageListener(new MessageListener<std_msgs.String>() {
@Override
public void onNewMessage(std_msgs.String message) {
log.info("I heard: \"" + message.getData() + "\"");
}
});
}
}
http://answers.ros.org/question/113436/rosjava-listener/ Duplicate