Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Error after adding new listener on android

Hi, I have launched a simple publisher on my linux pc with ros and then i tried to modify the pubsub tutorial to show messages published by ros machine on the phone screen. Logcat informs me that subscriber was succesfully registered but there are also some errors. In the end nothing appears on my android device screen. Could you help me resolve this problem?

Here is code: MainActivity

public class MainActivity extends RosActivity {

  private RosTextView<std_msgs.String> rosTextViewPublikowanie;

  public MainActivity() {
    // The RosActivity constructor configures the notification title and ticker
    // messages.
    super("Pubsub Tutorial", "Pubsub Tutorial");
  }

  @SuppressWarnings("unchecked")
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    rosTextViewPublikowanie = (RosTextView<std_msgs.String>) findViewById(R.id.text_publikowanie);
    rosTextViewPublikowanie.setTopicName("publikowanie");
    rosTextViewPublikowanie.setMessageType(std_msgs.String._TYPE);
    rosTextViewPublikowanie.setMessageToStringCallable(new MessageCallable<String, std_msgs.String>() {
      @Override
      public String call(std_msgs.String message) {
        return message.getData();
      }
    });
  }

  @Override
  protected void init(NodeMainExecutor nodeMainExecutor) {
    NodeConfiguration nodeConfiguration = NodeConfiguration.newPrivate();
    nodeConfiguration.setMasterUri(getMasterUri());
    nodeMainExecutor.execute(rosTextViewPublikowanie, nodeConfiguration);
  }

and a Listener

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();
    Subscriber<std_msgs.String> sub_publikowanie = connectedNode.newSubscriber("publikowanie", std_msgs.String._TYPE);
    sub_publikowanie.addMessageListener(new MessageListener<std_msgs.String>() {
      @Override
      public void onNewMessage(std_msgs.String message) {
        log.info("I heard: \"" + message.getData() + "\"");
      }
    });
  }

and Logcat

05-15 01:23:24.439: E/dalvikvm(23345): Could not find class 'java.util.concurrent.LinkedTransferQueue', referenced from method org.jboss.netty.util.internal.QueueFactory.createQueue
05-15 01:23:24.439: W/dalvikvm(23345): VFY: unable to resolve new-instance 2378 (Ljava/util/concurrent/LinkedTransferQueue;) in Lorg/jboss/netty/util/internal/QueueFactory;
05-15 01:23:24.479: E/dalvikvm(23345): Could not find class 'java.util.concurrent.LinkedTransferQueue', referenced from method org.jboss.netty.util.internal.QueueFactory.createQueue
05-15 01:23:24.479: W/dalvikvm(23345): VFY: unable to resolve new-instance 2378 (Ljava/util/concurrent/LinkedTransferQueue;) in Lorg/jboss/netty/util/internal/QueueFactory;
05-15 01:23:24.539: I/Registrar(23345): MasterXmlRpcEndpoint URI: http:/----/
05-15 01:23:24.599: I/Registrar(23345): Registering publisher: Publisher<PublisherDefinition<PublisherIdentifier<NodeIdentifier</android_gingerbread/ros_text_view, http:/----/>, TopicIdentifier</rosout>>, Topic<TopicIdentifier</rosout>, TopicDescription<rosgraph_msgs/Log, acffd30cd6b6de30f120938c17c593fb>>>>
05-15 01:23:24.909: I/Registrar(23345): Response<Success, Registered [/android_gingerbread/ros_text_view] as publisher of [/rosout], [http://Salon-Linux:42216/]>
05-15 01:23:24.909: I/DefaultPublisher(23345): Publisher registered: Publisher<PublisherDefinition<PublisherIdentifier<NodeIdentifier</android_gingerbread/ros_text_view, http:/-------/>, TopicIdentifier</rosout>>, Topic<TopicIdentifier</rosout>, TopicDescription<rosgraph_msgs/Log, acffd30cd6b6de30f120938c17c593fb>>>>
05-15 01:23:24.939: I/Registrar(23345): Registering subscriber: Subscriber<Topic<TopicIdentifier</publikowanie>, TopicDescription<std_msgs/String, 992ce8a1687cec8c8bd883ec73ca41d1>>>
05-15 01:23:24.959: I/Registrar(23345): Response<Success, Subscribed to [/publikowanie], [http://Salon-Linux:42897/]>
05-15 01:23:24.969: I/DefaultPublisher(23345): Subscriber registered: Subscriber<Topic<TopicIdentifier</publikowanie>, TopicDescription<std_msgs/String, 992ce8a1687cec8c8bd883ec73ca41d1>>>
05-15 01:23:25.029: E/UpdatePublisherRunnable(23345): java.lang.RuntimeException: java.net.UnknownHostException: Salon-Linux