using java-actionlib on android doesn't work
Hello ROS community!
I have following set-up:
- an Ubuntu in a Virtual Box (running in Windows 7) (192.168.0.72)
- an Android Device (192.168.0.68)
Network setup:
- Host Operating System (Windows 7, IP=192.168.0.59 via DHCP) is connected via LAN to the company network.
- Virtual Box Network settings: Bridged Adapter
- Ubuntu in Virtual Box has 192.168.0.72 (DHCP)
- Android Device is connected via WLAN (DHCP) to the company network
- I can ping all devices from Windows 7 and Ubuntu
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 ...