ROS Android Connection Failure
I have two apps at play. One app (A) forms a connection successfully, but the other app (B) fails unintendedly. Any incite into my problem would be greatly appreciated:
App A launches a RosActivity to form a connection between tablet and PC. App B launches a NodeMainExecutorService to form a connection between tablet and PC.
Both apps use the exact same host name, and master URI (same tablet, same PC). Within the Java debugger, I have verified that host and URI values are the same between apps for my NodeConfiguration.
I have also verified that the NodeMainExecutorService is running. I'm reaching the point where remote procedure calls are failing, and I cannot tunnel any deeper with the Java debugger.
I've read a considerable amount of the RosAndroid source. My understanding is RosActivity is nothing but a convenience wrapper to start the NodeMainExecutorService so there's nothing I should need to do to connect with ROS other than starting the NodeMainExecutorService and supplying the correct host and URI.
My code in app B is as follows:
public class Ros {
private static final String TAG = Ros.class.getSimpleName();
private static final NodeMainExecutorServiceConnection s_connection = new NodeMainExecutorServiceConnection();
private static NodeMainExecutorService s_service = null;
public static void initialize() {
Intent intent = new Intent(App.context(), NodeMainExecutorService.class);
intent.setAction("org.ros.android.ACTION_START_NODE_RUNNER_SERVICE");
intent.putExtra("org.ros.android.EXTRA_NOTIFICATION_TICKER", "");
intent.putExtra("org.ros.android.EXTRA_NOTIFICATION_TITLE", "");
App.context().startService(intent);
App.context().bindService(intent, s_connection, Context.BIND_AUTO_CREATE);
}
public static void shutdown() {
App.context().unbindService(s_connection);
App.context().stopService(new Intent(App.context(), NodeMainExecutorService.class));
}
public static void start(MasterLocal master) {
final String host = master.profile().getHost().get();
final URI uri = Validation.uri("https://" + master.profile().getIpAddress() + ":11311");
s_service.setRosHostname(host);
s_service.setMasterUri(uri);
s_service.execute(master, NodeConfiguration.newPublic(host, uri).setNodeName("App_master_node_for_bot_" + master.profile().getName()));
}
public static void stop(MasterLocal masterLocal) {
s_service.shutdownNodeMain(masterLocal);
}
private static final class NodeMainExecutorServiceConnection implements ServiceConnection {
@Override
public void onServiceConnected(ComponentName name, IBinder binder) {
s_service = ((NodeMainExecutorService.LocalBinder) binder).getService();
}
@Override
public void onServiceDisconnected(ComponentName name) {
s_service = null;
}
}
}
Please let me know if you see any errors in my code/logic, if I'm missing any fundamental RosAndroid calls, or if this simply cannot be done.
Also the followinng error logs may be of interest. Basically the connection fails after trying to register my first publisher:
E/Registrar: Exception caught while communicating with master. Handshake failed.
I/DefaultPublisher: Publisher registration failed: Publisher<PublisherDefinition<PublisherIdentifier<NodeIdentifier</App_master_node, http://10.0.0.242:46839/>, TopicIdentifier</rosout>>, Topic<TopicIdentifier</rosout>, TopicDescription<rosgraph_msgs/Log, acffd30cd6b6de30f120938c17c593fb>>>>
Thank you very much for your time!
are there any error messages or warnings? Do you observe anything else which you believe is related to B "failing"?
Is the title of your question (part of) an error message you see somewhere?
I can't help you (no experience with Android), but I have a hard time finding an explicit reference to an error message, failure code or other form of output from which you deduce things don't work in your question text.
It might help others help you if you could make that a little clearer.
I just noticed this:
in the error you show.
Afaik, there is no support for using HTTPS with
roscore
.Are you sure your
A
andB
are using the same value for the master URI?If you remove the
s
(ie:http
) does it work?Thanks for taking a look. RosAndroid requires absolute URIs hence the use of HTTPS. It also uses remote procedure calls to run nodes which I'm pretty sure uses HTTPS. I've edited the logs to show only the errors (MasterXmlRpcEndpoint URI: https://10.0.0.93:11311 was confirmation that the URI was valid). I'm 100% sure the master URIs of A and B are identical as I inspected the memory with the Java debugger.