Ask Your Question
0

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();
rosCore.start();
try {
  rosCore.awaitStart();
} catch (Exception e) {
  throw new RuntimeException(e);
}
talker = new Talker();

nodeConfiguration.setMasterUri(rosCore.getUri());

and add:

nodeConfiguration.setMasterUri(URI.create("http://192.168.13.7:11311"));

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
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * 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.
 */

package org.ros.android.tutorial.pubsub;

import java.net.URI;

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

    /**
     * @author damonkohler@google.com (Damon Kohler)
     */
    public class MainActivity extends RosActivity {

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

ker;

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

  @SuppressWarnings("unchecked")
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    rosTextView = (RosTextView<org.ros.message.std_msgs.String>) findViewById(R.id.text);
    rosTextView.setTopicName("/chatter");
    rosTextView.setMessageType("std_msgs/String");
    rosTextView
        .setMessageToStringCallable(new MessageCallable<String, org.ros.message.std_msgs.String>() {
          @Override
          public String call(org.ros.message.std_msgs.String message) {
            return message.data;
          }
        });
  }

  @Override
  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("http://192.168.13.7:11311"));
    nodeMainExecutor.execute(talker, nodeConfiguration);
    nodeMainExecutor.execute(rosTextView, nodeConfiguration);
  }

  @Override
  protected void onDestroy() {
    super.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 ...
(more)
edit retag flag offensive close merge delete

Comments

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

amigo gravatar imageamigo ( 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 imagerosdai ( 2012-04-11 03:40:43 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
1

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("http://192.168.13.7:11311"));

edit flag offensive delete link more
0

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

amigo gravatar image

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

nodeConfiguration.setMasterUri(URI.create("http://192.168.13.7:11311"));

Did you try the patch here

http://answers.ros.org/question/12771/running-android_tutorial_pubsub?answer=18845#post-id-18845

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

Stats

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

Seen: 1,591 times

Last updated: Apr 11 '12