ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

rosdai's profile - activity

2014-01-28 17:25:23 -0500 marked best answer how to report master connection status in android

Hi,

I'm working on an android application which connects a master on PC. I wonder if there's any way to feedback the current connection status in android user interface ? I can see the status in logcat in eclipse, but is there a way to show it to the android user?

one of the idea is to catch the registration error, and make a toast to handle it. is it possible to catch the registration error? if yes, where to catch it?

following is the logcat from eclipse. i want to tell the user "connecting to master failed" whenever the following error occurs.

04-17 12:16:50.856: E/Registrar(17158): Exception caught while communicating with master.
04-17 12:16:50.856: E/Registrar(17158): java.lang.RuntimeException: java.net.ConnectException: orome.intern.vmi.ei.tum.de/192.168.13.7:11311 - Connection refused
04-17 12:16:50.856: E/Registrar(17158):     at org.ros.internal.node.xmlrpc.XmlRpcClientFactory$1.invoke(XmlRpcClientFactory.java:157)
04-17 12:16:50.856: E/Registrar(17158):     at $Proxy0.unregisterPublisher(Native Method)
04-17 12:16:50.856: E/Registrar(17158):     at org.ros.internal.node.client.MasterClient.unregisterPublisher(MasterClient.java:161)
04-17 12:16:50.856: E/Registrar(17158):     at org.ros.internal.node.client.Registrar$3$1.call(Registrar.java:170)
04-17 12:16:50.856: E/Registrar(17158):     at org.ros.internal.node.client.Registrar$3$1.call(Registrar.java:167)
04-17 12:16:50.856: E/Registrar(17158):     at org.ros.internal.node.client.Registrar.callMaster(Registrar.java:111)
04-17 12:16:50.856: E/Registrar(17158):     at org.ros.internal.node.client.Registrar.access$100(Registrar.java:51)
04-17 12:16:50.856: E/Registrar(17158):     at org.ros.internal.node.client.Registrar$3.call(Registrar.java:167)
04-17 12:16:50.856: E/Registrar(17158):     at org.ros.internal.node.client.Registrar$3.call(Registrar.java:164)
04-17 12:16:50.856: E/Registrar(17158):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
04-17 12:16:50.856: E/Registrar(17158):     at java.util.concurrent.FutureTask.run(FutureTask.java:138)
04-17 12:16:50.856: E/Registrar(17158):     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:444)
04-17 12:16:50.856: E/Registrar(17158):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
04-17 12:16:50.856: E/Registrar(17158):     at java.util.concurrent.FutureTask.run(FutureTask.java:138)
04-17 12:16:50.856: E/Registrar(17158):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
04-17 12:16:50.856: E/Registrar(17158):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
04-17 12:16:50.856: E/Registrar(17158):     at java.lang.Thread.run(Thread.java:1019)
04-17 12:16:50.856: E/Registrar(17158): Caused by: java.net.ConnectException: orome.intern.vmi.ei.tum.de/192.168.13.7:11311 - Connection refused
04-17 12:16:50.856: E/Registrar(17158):     at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl ...
(more)
2014-01-28 17:25:21 -0500 marked best answer error setting localhost on android

I'm trying to use this line to set localhost on Android

String localhost = InetAddressFactory.newNonLoopback().getHostAddress();
nodeConfiguration = NodeConfiguration.newPublic(localhost, masterUri);

then the following error occurred. If I set localhost to the android Ip directly, for example String localhost = "192.168.13.111", the program is able to run.

E/AndroidRuntime(5551): FATAL EXCEPTION: main
E/AndroidRuntime(5551): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.dsi.ant.antplusdemo/com.dsi.ant.antplusdemo.ANTPlusDemo}: java.lang.NullPointerException
E/AndroidRuntime(5551):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1768)
E/AndroidRuntime(5551):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)
E/AndroidRuntime(5551):     at android.app.ActivityThread.access$1500(ActivityThread.java:123)
E/AndroidRuntime(5551):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
E/AndroidRuntime(5551):     at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(5551):     at android.os.Looper.loop(Looper.java:130)
E/AndroidRuntime(5551):     at android.app.ActivityThread.main(ActivityThread.java:3835)
E/AndroidRuntime(5551):     at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(5551):     at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime(5551):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
E/AndroidRuntime(5551):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
E/AndroidRuntime(5551):     at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(5551): Caused by: java.lang.NullPointerException
E/AndroidRuntime(5551):     at org.ros.node.NodeConfiguration.copyOf(NodeConfiguration.java:78)
E/AndroidRuntime(5551):     at DefaultNodeMainExecutor.execute(DefaultNodeMainExecutor.java:110)
E/AndroidRuntime(5551):     at org.ros.node.DefaultNodeMainExecutor.execute(DefaultNodeMainExecutor.java:134)
E/AndroidRuntime(5551):     at com.dsi.ant.antplusdemo.ANTPlusDemo.connectmaster(ANTPlusDemo.java:506)
E/AndroidRuntime(5551):     at com.dsi.ant.antplusdemo.ANTPlusDemo.onCreate(ANTPlusDemo.java:414)
E/AndroidRuntime(5551):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
E/AndroidRuntime(5551):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1722)
E/AndroidRuntime(5551):     ... 11 more

Strangely, sometimes, for no reason, this line would work. but after a while, the same problem occurs again.

2014-01-28 17:25:20 -0500 marked best answer how to reconnect master on PC

Hi all,

I have an application for android which sends data from a nodemain to master on PC. onCreate I used connectmaster() to run a new NodeMain called Sender. now I want to add a reconnect function, which will kill this Sender and connect it to Master again.

I tried the following code:

   private void reconnectMaster()
   {
       disconnectMaster();
       try {
           Thread.sleep(3000);
       } catch (InterruptedException e) {
           e.printStackTrace();
       }
       Log.v(TAG, "shut down node sender");
       connectmaster();
   }

   private void disconnectMaster(){

       nodeMainExecutor.shutdownNodeMain(sender);

   }

   public void connectmaster(){
       try{
           String Uri = ((EditText)findViewById(R.id.hostvalue)).getText().toString();
           Integer port = Integer.parseInt(((EditText)findViewById(R.id.portvalue)).getText().toString());
           URI masterUri = URI.create("http://"+ Uri + ":" + port);
           Log.v("Sender", "setMasterURI");
           String localhost = InetAddressFactory.newNonLoopback().getHostAddress();
//           String localhost = "192.168.13.111";
           Log.v("Sender", "setlocalhost");

           nodeConfiguration = NodeConfiguration.newPublic(localhost, masterUri);
           Log.v("Sender", "nodeConfiguration");

           nodeConfiguration.setNodeName("Ant_Sender");
           Log.v("Sender", "nodeName");     

           }catch (Exception e) {
           e.printStackTrace();
           Log.e("Sender", "nodeConfiguration error");
       }

       Log.i("SDM", "create new Sender"); 
       sender = new Sender();
       nodeMainExecutor.execute(sender, nodeConfiguration);

   }

and my Sender has the following code:

public class Sender implements NodeMain {

   public Publisher<ant_msgs.sdm> publisherSDM;
   public Publisher<ant_msgs.wgt> publisherWGT;
   public Publisher<ant_msgs.hrm> publisherHRM;
   private Node node;

public Sender() {
//     TODO Auto-generated constructor stub

}

  @Override
  public GraphName getDefaultNodeName() {
    return new GraphName("Sender");
  }

  @Override
  public void onStart(Node node) {
      Log.i("Sender", "enter onStart");
      this.node = node;
      publisherSDM = node.newPublisher("ANT", ant_msgs.sdm._TYPE);

  }

  public void publishSDM(float speed, float cadence, float distance, long stride, String data)
      {
      Log.i("Sender", "publishSDM enter");

      ant_msgs.sdm msg = publisherSDM.newMessage();
      msg.speed(speed);
      msg.cadence(cadence);
      msg.distance(distance);
      msg.stride(stride);
      msg.data(data);
      publisherSDM.publish(msg);
  }

  @Override
  public void onShutdown(Node node) {
      Log.i("sender", "onShutdown");
      node.shutdown();
      node = null;
  }

  @Override
  public void onShutdownComplete(Node node) {
  }
}

but every time i click on the button reconnect, hundreds of "onShutDown" is shown in my logcat (which is in my Sender's shutdown method log.v), and then the application broke down

04-16 11:54:17.437: I/Registrar(7170): Unregistering publisher: Publisher<PublisherDefinition<PublisherIdentifier<NodeSlaveIdentifier</Ant_Sender, http://192.168.13.111:42290>, TopicIdentifier</rosout>>, Topic<TopicIdentifier</rosout>, TopicDescription<rosgraph_msgs/Log,acffd30cd6b6de30f120938c17c593fb>>>>
04-16 11:54:17.437: W/Registrar(7170): Registrar no longer running, request ignored.
04-16 11:54:17.757: I/DefaultPublisher(7170): Publisher unregistration failed: Publisher<PublisherDefinition<PublisherIdentifier<NodeSlaveIdentifier</Ant_Sender, http://192.168.13.111:42290>, TopicIdentifier</rosout>>, Topic<TopicIdentifier</rosout>, TopicDescription<rosgraph_msgs/Log,acffd30cd6b6de30f120938c17c593fb>>>>

04-16 11:53:28.430: E/dalvikvm(5334): Thread creation failed (err=No such file or directory)
04-16 11:53:28.430: D/AndroidRuntime(5334): Shutting down VM
04-16 11:53:28.430: W/dalvikvm(5334): threadid=1: thread exiting with uncaught exception (group=0x40018560)
04-16 11:53:28.437: E/AndroidRuntime(5334): FATAL EXCEPTION: main
04-16 11:53:28.437: E/AndroidRuntime(5334): java.lang.OutOfMemoryError: thread creation failed
04-16 11:53:28.437: E/AndroidRuntime(5334):     at java.lang.VMThread.create(Native Method)
04-16 11:53:28.437: E/AndroidRuntime(5334):     at java.lang.Thread ...
(more)
2014-01-28 17:25:17 -0500 marked best answer modifying android_tutorial_pubsub. able to connect master on pc but roswtf and rxgraph suggests error

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)
2014-01-28 17:25:17 -0500 marked best answer publish message in main class instead of talker

Hi all,

I'm working on a project that receives data from a sensor and sends the data back to pc using rosjava.

I'm trying to realize this function on the base of rosjava_tutorial_pubsub. I realized almost all the tutorials tend to use NodeMainExecute to run a node, and the publish function is implemented in the Talker.java itself.

Since my data are retrieved and stored in the main class and updates constantly, i want to publish my message in main class, which means moving the following snippet from talker.java into main.java.

org.ros.message.std_msgs.String str = publisher.newMessage();
str.data = mdata;
publisher.publish(str);

how should I modify the main.java? Should I add a variable Publisher publisher in the beginning?


actually I want to run roscore on PC.

2014-01-28 17:25:11 -0500 marked best answer building rosjava_core

I was trying to reinstall rosjava_core from source. I uninstalled debian rosjava_core, and downloaded the newest version from source hg clone https://rosjava.googlecode.com/hg/ rosjava_core. Then I tried to follow this tutorial (There seems to be an update for the rosjava_core on 31.March. the following two steps are deleted

./gradlew rosjava_bootstrap:install
rosrun rosjava_bootstrap install_generated_modules.py rosjava

). but as I run ./gradlew install the follwing failure occured. it was no problem when I first installed rosjava from debian... I noticed this is a problem when installing docs. I don't actually need them. can I skip this step?

...
> Building > :docs:javadoc > Resolving dependencies ':rosjava_tutorial_pubsub:co:docs:javadoc
/home/evelyn/ros_workspace/rosjava_core/apache_xmlrpc_server/src/main/java/org/apache/xmlrpc/webserver/WebServer.java:72: warning - Tag @Link: reference not found: ServletWebServer
1 warning
:docs:install
sphinx-build -b html -d build/doctrees   src/main/sphinx build/html
Running Sphinx v1.0.1
loading pickled environment... not yet created
building [html]: targets for 5 source files that are out of date
updating environment: 5 added, 0 changed, 0 removed
reading sources... [ 20%] best_practices
reading sources... [ 40%] building
reading sources... [ 60%] getting_started
reading sources... [ 80%] index
reading sources... [100%] overview

looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [ 20%] best_practices
writing output... [ 40%] building
writing output... [ 60%] getting_started

Exception occurred:
  File "/usr/lib/python2.7/dist-packages/pygments/lexers/__init__.py", line 80, in get_lexer_by_name
    raise ClassNotFound('no lexer for alias %r found' % _alias)
ClassNotFound: no lexer for alias u'groovy' found
The full traceback has been saved in /tmp/sphinx-err-nCDX3T.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
Either send bugs to the mailing list at <http://groups.google.com/group/sphinx-dev/>,
or report them in the tracker at <http://bitbucket.org/birkenfeld/sphinx/issues/>. Thanks!
make: *** [html] Error 1

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':docs:install'.
> Command 'make' finished with (non-zero) exit value 2.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 19.881 secs
2014-01-28 17:25:09 -0500 marked best answer How to run listener.cpp on PC to receive message from Android (using Rosjava)?

The goal is to send message from Android and receive it on my PC. My idea is to use this tutorial to build a package on PC containing an executable "listener". Then I write an android application based on rosjava. and set the MasterUri to PC (which is http://192.168.13.7:11311) my code is like this:

String hostLocal = InetAddressFactory.newNonLoopback().getHostAddress();
String hostMaster = "192.168.13.7";
URI uri = URI.create("http://" + hostMaster + ":" + "11311");
NodeConfiguration nodeConfigurationTalker = NodeConfiguration.newPublic(hostLocal, uri);

talker = new Talker;
nodeRunner.run(tistener, nodeConfigurationTalker);

Then I started roscore on PC and talker on android AVD (target 10), remembering to export ROS_MASTER_URI=http://localhost:11311 and export ROS_IP=192.168.13.7.

but then there occurs this error

java.lang.RuntimeException:java.net.ConnectException:10.0.2.15/10.0.2.15:58353 - Connection refused

roswtf suggests Could not connect the android Node. and of course i couldn't receive anything on my pc...

I wonder what could be the cause. Do I need to set up anything else to combine c++ and rosjava? what could be the correct network setup? Is there any tutorial which is intended for communication between android and PC? The android_tutorial_pubsub builds its roscore in android itself.

2014-01-28 17:25:06 -0500 marked best answer building ros_core using gradle and maven3

I've been looking for answers for 2 days, haven't found anything. someone please help me out.

so I was following this Tutorial link text trying to build the ros_core. but every time I come to step 4, the same error comes up.

evelyn@evelyn-VirtualBox:/opt/ros/electric/stacks/rosjava_core/rosjava_bootstrap$ rosrun rosjava_bootstrap install_generated_modules.py rosjava

Installing: message.std_msgs
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building message.std_msgs 0.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for ros.rosjava_core:rosjava_bootstrap:jar:0.0.0-SNAPSHOT is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.888s
[INFO] Finished at: Mon Mar 26 14:49:18 CEST 2012
[INFO] Final Memory: 2M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project message.std_msgs: Could not resolve dependencies for project ros:message.std_msgs:jar:0.0.0-SNAPSHOT: Could not find artifact ros.rosjava_core:rosjava_bootstrap:jar:0.0.0-SNAPSHOT -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.

[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
Failed!
Module directory not cleaned up: /tmp/tmprNqMPE

I guess this is a maven issue. but I don't know how to solve it. using mvn --version I get the following feedback:

Apache Maven 3.0.4 (r1232337; 2012-01-17 09:44:56+0100)
Maven home: /usr/local/apache-maven/apache-maven-3.0.4
Java version: 1.6.0_31, vendor: Sun Microsystems Inc.
Java home: /usr/lib/jvm/jdk1.6.0_31/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "2.6.38-13-generic", arch: "i386", family: "unix"

btw the reason why I'm building up ros_core is that I want to get the newest version of rosjava jars, so that I can finally follow the codes and tutorials. Anyone knows whether I can download them somewhere? is there a rosjava library?

2012-10-10 00:49:24 -0500 received badge  Notable Question (source)
2012-10-10 00:49:24 -0500 received badge  Popular Question (source)
2012-10-10 00:49:24 -0500 received badge  Famous Question (source)
2012-10-05 05:34:50 -0500 received badge  Notable Question (source)
2012-10-05 05:34:50 -0500 received badge  Popular Question (source)
2012-10-05 05:34:50 -0500 received badge  Famous Question (source)
2012-09-20 03:44:16 -0500 received badge  Notable Question (source)
2012-09-20 03:44:16 -0500 received badge  Famous Question (source)
2012-09-20 03:44:16 -0500 received badge  Popular Question (source)
2012-09-06 16:05:59 -0500 received badge  Famous Question (source)
2012-09-06 16:05:59 -0500 received badge  Notable Question (source)
2012-09-03 00:20:14 -0500 received badge  Popular Question (source)
2012-09-03 00:20:14 -0500 received badge  Famous Question (source)
2012-09-03 00:20:14 -0500 received badge  Notable Question (source)
2012-08-30 12:37:01 -0500 received badge  Famous Question (source)
2012-08-30 12:37:01 -0500 received badge  Popular Question (source)
2012-08-30 12:37:01 -0500 received badge  Notable Question (source)
2012-08-28 01:05:51 -0500 received badge  Popular Question (source)
2012-08-28 01:05:51 -0500 received badge  Notable Question (source)
2012-08-28 01:05:51 -0500 received badge  Famous Question (source)
2012-08-21 09:00:33 -0500 received badge  Notable Question (source)
2012-08-21 09:00:33 -0500 received badge  Famous Question (source)
2012-08-21 09:00:33 -0500 received badge  Popular Question (source)