ROS Android confuses Master IP

asked 2020-03-08 07:44:40 -0500

keivanh gravatar image

I am following "android_core/android_tutorial_pubsub" example, but instead of talker I am registering a subscriber.

My setup is like this:

1- ROS Master - Ubuntu 18.04 - URI:

2- Android studio is running on second machine - Ubuntu 18.04 - IP:

3- Testing device - Android device (not emulator) - IP: - WIFI

When app lunches, I can see it is being add to "rosnode" and "chatter" is added to rostopics (in subscriber section), so everything looks OK up to here.

But many times subscriber callback does not being called, and few time (1 of 10 times) everything work OK and I get talker messages in Android. Only error I get in Android console is this:

/UpdatePublisherRunnable: java.lang.RuntimeException: failed to connect to ubuntu/ (port 44503) from / (port 41016) after 60000ms: isConnected failed: ECONNREFUSED (Connection refused)

I get one error line (with random port number) every time I start "talker" app in ROS master machine. Interesting point is, why it tries to connect to "" which is my Android machine not ROS master machine, This is how I start the RosActivity:

public RosNode() throws URISyntaxException{
    super("ChatterTest", "ChatterTest", new URI(""));

And I don't have any reference to "" in my code.

My first guess was, it has something to do with ADB, but it was not true. I disconnected mobile device, stopped the application, stopped the ROS core, and run everything again, again I see android being added in nodes and topics, but nothings happens until I plugin device again and that error line with exact time of starting of talker appears in Android Studio logcat window.

Only way to make it work is it to install application with Android studio and then restart phone, it looks IP of Adb somehow being cache and ROS Java take that as ROS master IP.

edit retag flag offensive close merge delete