listener rosjava [closed]

asked 2013-12-27 16:23:11 -0600

uzair gravatar image

updated 2013-12-27 19:21:42 -0600

tfoote gravatar image

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() + "\"");

  }

});

}

}

edit retag flag offensive reopen merge delete

Closed for the following reason duplicate question by tfoote
close date 2013-12-27 19:22:00

Comments

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

tfoote gravatar imagetfoote ( 2013-12-27 19:21:57 -0600 )edit

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

uzair gravatar imageuzair ( 2013-12-28 09:23:00 -0600 )edit

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

tfoote gravatar imagetfoote ( 2013-12-28 10:44:50 -0600 )edit

oh..thanks!

uzair gravatar imageuzair ( 2013-12-28 11:04:54 -0600 )edit