Hello ROS community!
I have following set-up:
Network setup:
I want to run the Fibonacci tutorial from the actionlib tutorials (https://code.google.com/p/rosjava/source/browse/actionlib_java/src/tutorials/java/org/ros/actionlib/example/FibonacciActionClient.java">click). When both, the client and the server, run on Ubuntu, everything works.
As soon as the client runs on android, it doesn't work anymore. The client says "Waiting for action server to start". This is the client code:
package org.ros.android.tutorial.pubsub;
import java.net.InetSocketAddress;
import java.net.URI;
import java.net.URISyntaxException;
import org.ros.actionlib.example.RunFibonacciSimpleActionClient;
import org.ros.address.BindAddress;
import org.ros.node.DefaultNodeRunner;
import org.ros.node.NodeConfiguration;
import org.ros.node.NodeRunner;
import org.ros.tutorials.pubsub.R;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
/**
* @author damonkohler@google.com (Damon Kohler)
*/
public class MainActivity extends Activity {
@SuppressWarnings("static-access")
public MainActivity() {
System.setProperty("java.net.preferIPv6Addresses", "false");
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
@Override
protected void onResume() {
super.onResume();
String masterUri = "http://192.168.0.72:11311";
String host = "192.168.0.68";
URI uri = null;
try {
uri = new URI(masterUri);
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
NodeConfiguration configuration = NodeConfiguration.newPublic(host, uri);
//NodeConfiguration configuration = NodeConfiguration.newPrivate();
configuration.setNodeName("fibClientNode");
configuration.setMasterUri(uri);
NodeRunner runner = DefaultNodeRunner.newDefault();
RunFibonacciSimpleActionClient fibClient = new RunFibonacciSimpleActionClient();
Log.v("topics", configuration.getMasterUri().toString());
fibClient.run(runner, configuration);
}
@Override
protected void onPause() {
super.onPause();
}
}
This is the important server code:
public static void main() {
try {
// user code implementing the SimpleActionServerCallbacks interface
FibonacciSimpleActionServerCallbacks impl = new FibonacciSimpleActionServerCallbacks();
FibonacciActionSpec spec = new FibonacciActionSpec();
final FibonacciSimpleActionServer sas =
spec.buildSimpleActionServer("fibonacci_server", impl, true);
String masterUri = "http://192.168.0.72:11311";
String host = "192.168.0.72";
URI uri = null;
try {
uri = new URI(masterUri);
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
NodeConfiguration configuration = NodeConfiguration.newPublic(host, uri);
configuration.setNodeName("fibServerNode");
NodeRunner runner = DefaultNodeRunner.newDefault();
runner.run(new NodeMain() {
@Override
public void onStart(Node node) {
sas.addClientPubSub(node);
}
@Override
public void onShutdown(Node node) {
}
@Override
public void onShutdownComplete(Node node) {
}
}, configuration);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Additional information:
ubuntu@ubuntu-VirtualBox:~$ rosnode list -a http://192.168.0.68:33448 /fibClientNode http://192.168.0.72:45874 /fibServerNode http://192.168.0.72:58875/ /rosout
ubuntu@ubuntu-VirtualBox:~$ roswtf Loaded plugin tf.tfwtf No package or stack in context ================================================================================ 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... ... done running graph rules
Online checks summary:
Found 3 warning(s). Warnings are things that may be just fine, but are sometimes at fault
WARNING Node [/fibServerNode] is not connected to anything WARNING Node [/fibClientNode] is not connected to anything WARNING The following nodes are unexpectedly connected: * unknown (http://192.168.0.72:45874/)->/rosout (/rosout) * unknown (http://192.168.0.68:33448/)->/rosout (/rosout)
Found 1 error(s).
ERROR The following nodes should be connected but aren't: * /fibServerNode->/fibClientNode (/result) * /fibServerNode->/fibClientNode (/feedback) * /fibClientNode->/fibServerNode (/cancel) * /fibClientNode->/fibServerNode (/goal) * /fibServerNode->/fibClientNode (/status)
on Ubuntu: ROS_IP is 192.168.0.72, ROS_MASTER_URI = http://192.168.0.72:11311
I was hoping, someone could tell me, why the client and server don't communicate. rosnode finds all nodes, IP addresses seem to be correct, but for some reason they are not really connected.
I finally found the solution for the problem! It was the android version. I used Android Froyo and I didn't get any errors, but it doesn't work. I tried it with a simulator running gingerbread and it worked for me!
Using Froyo seems to work at first glance because the nodes and topics on android device are found by roscore. But for some reason communication is not possible with Froyo. I'm using CyanogenMod now for running gingerbread on my android device, since there is no official update and the ROS communication works (tested with Fibonacci tutorial)!
This is a communication problem. When you create your NodeConfiguration, you pass the IP of the master as your local node IP. You should set host to 192.168.0.68, or have you code figure it out dynamically. See: http://www.ros.org/wiki/rosjava/Overview/Nodes#NodeConfiguration
EDIT: This could also be a problem with the windows firewall blocking inbound or outbound ROS connections. Since ROS listens on dynamic ports, and connections are made in both directions, the only real solution is to disable the firewall entirely.
I guess it's a communication problem. You should probably also set ROS_IP on the client (to 192.168.0.68).
Asked: 2012-01-10 07:36:19 -0500
Seen: 445 times
Last updated: Jan 17 '12
ROS Answers is licensed under Creative Commons Attribution 3.0 Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.