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

ROS Android Connection Failure

asked 2021-03-03 14:05:31 -0500

Smiley98 gravatar image

updated 2021-03-04 07:26:10 -0500

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!

edit retag flag offensive close merge delete

Comments

One app (A) forms a connection successfully, but the other app (B) fails unintendedly

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.

gvdhoorn gravatar image gvdhoorn  ( 2021-03-04 04:59:01 -0500 )edit

I just noticed this:

MasterXmlRpcEndpoint URI: https://10.0.0.93:11311

in the error you show.

Afaik, there is no support for using HTTPS with roscore.

Are you sure your A and B are using the same value for the master URI?

If you remove the s (ie: http) does it work?

gvdhoorn gravatar image gvdhoorn  ( 2021-03-04 05:00:33 -0500 )edit

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.

Smiley98 gravatar image Smiley98  ( 2021-03-04 07:25:38 -0500 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2021-03-04 08:38:43 -0500

gvdhoorn gravatar image

RosAndroid requires absolute URIs hence the use of HTTPS

I'm not sure I follow.

https is the secure version of http.

Afaik, there is no SSL transport available in roscore, so specifying a HTTPS protocol in the URI and pointing it to tcp://:11311 of your ROS pc (which runs roscore) is not supposed to work (again: afaik).

I would assume that's what's causing the "handshake failure" (as your application expects an SSL capable endpoint, but roscore doesn't offer it).

What do you mean by "absolute URIs" and how is that connected to HTTPS?

edit flag offensive delete link more

Comments

You're right, I'm speaking complete nonsense! I wasn't paying attention to how ROS connects, uses HTTP. Removing 1 letter fixed everything.

Smiley98 gravatar image Smiley98  ( 2021-03-04 09:11:10 -0500 )edit

wasn't paying attention to how ROS connects, uses HTTP

just to clarify for future readers: HTTP is only used by the XML-RPC server and clients which are part of roscore and ROS 1 nodes.

It's not used for data exchange.

gvdhoorn gravatar image gvdhoorn  ( 2021-03-04 09:13:08 -0500 )edit

Could you please mark the question as answered by ticking the checkmark (✓) to the left of the answer if you feel it has been answered? Thanks.

gvdhoorn gravatar image gvdhoorn  ( 2021-03-04 09:14:04 -0500 )edit

Question Tools

Stats

Asked: 2021-03-03 14:05:31 -0500

Seen: 179 times

Last updated: Mar 04 '21