ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

modifying android_tutorial_pubsub. able to connect master on pc but roswtf and rxgraph suggests error

asked 2012-03-28 04:50:53 -0500

rosdai gravatar image

updated 2014-01-28 17:11:47 -0500

ngrennan gravatar image

Hi ROS community,

I'm trying to modify the android_tutorial_pubsub in hope that the roscore is started on my PC instead of on Android. I started roscore and set ROS_IP as well as ROS_MASTER_URI.

All I did to the code was delete

rosCore = RosCore.newPrivate();
try {
} catch (Exception e) {
  throw new RuntimeException(e);
talker = new Talker();


and add:


so the code looks like this

 * Copyright (C) 2011 Google Inc.
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.



import android.os.Bundle;
//import org.ros.RosCore;
import org.ros.node.NodeConfiguration;
import org.ros.node.NodeMainExecutor;
import org.ros.tutorials.pubsub.R;
import org.ros.tutorials.pubsub.Talker;

     * @author (Damon Kohler)
    public class MainActivity extends RosActivity {

    //  private RosCore rosCore;
      private RosTextView<org.ros.message.std_msgs.String> rosTextView;
      private Talker tal


  public MainActivity() {
    super("Pubsub Tutorial", "Pubsub Tutorial");

  public void onCreate(Bundle savedInstanceState) {
    rosTextView = (RosTextView<org.ros.message.std_msgs.String>) findViewById(;
        .setMessageToStringCallable(new MessageCallable<String, org.ros.message.std_msgs.String>() {
          public String call(org.ros.message.std_msgs.String message) {

  protected void init(NodeMainExecutor nodeMainExecutor) {
//    rosCore = RosCore.newPrivate();
//    rosCore.start();
//    try {
//      rosCore.awaitStart();
//    } catch (Exception e) {
//      throw new RuntimeException(e);
//    }
    talker = new Talker();
    NodeConfiguration nodeConfiguration = NodeConfiguration.newPrivate();
//    nodeConfiguration.setMasterUri(URI.create(""));
    nodeMainExecutor.execute(talker, nodeConfiguration);
    nodeMainExecutor.execute(rosTextView, nodeConfiguration);

  protected void onDestroy() {
    // RosCore should be shut down last since running Nodes will attempt to
    // unregister at shutdown.
//    rosCore.shutdown();

when running, android is able to show Hello World n. so I assume android is then the two nodes talker and ros_text_view is able to connect the my master on PC. but as I called roswtf, i got the following error:

Loaded plugin tf.tfwtf
Package: beginner_tutorials
Static checks summary:

No errors or warnings
Beginning tests of your ROS graph. These may take awhile...
analyzing graph...
... done analyzing graph
running graph rules...
connection to [/android_gingerbread/ros_text_view] timed out
connection to [/rosjava_tutorial_pubsub/talker] timed out
... done running graph rules

Online checks summary:

Found 2 error(s).

ERROR Could not contact the following nodes:
 * /android_gingerbread/ros_text_view
 * /rosjava_tutorial_pubsub/talker

ERROR The following nodes should be connected but ...
edit retag flag offensive close merge delete


Did you mean to comment out the line // nodeConfiguration.setMasterUri(URI.create(""));?

amigo gravatar image amigo  ( 2012-04-06 06:41:37 -0500 )edit

sorry the code was wrong. In my own code this line wasn't commented out

rosdai gravatar image rosdai  ( 2012-04-11 03:40:43 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2012-04-11 03:42:22 -0500

rosdai gravatar image

turned out this is a issue with AVD. If I use AVD, and need to forward port, which is very inconvenient.

also NodeConfiguration nodeConfiguration = NodeConfiguration.newPrivate(); set Master default to itself. change it to NodeConfiguration nodeConfiguration = NodeConfiguration.newPublic() and then nodeConfiguration.setMasterUri(URI.create(""));

edit flag offensive delete link more

answered 2012-04-06 06:44:47 -0500

amigo gravatar image

Did you mean to comment out the line in your code:


Did you try the patch here

It uses setMasterUri(getMasterUri()). That worked for me.

Or maybe you have a network problem. What is your setup?

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2012-03-28 04:50:53 -0500

Seen: 1,691 times

Last updated: Apr 11 '12