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]

asked 2013-12-27 16:32:57 -0600

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 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:20

Comments

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

tfoote gravatar image tfoote  ( 2013-12-27 19:22:17 -0600 )edit