rosjava_tutorial_services on android
Hello.
I am trying to create a ROS client server application in android. I'm using the rosjavatutorialservices. If i create both server and client on the android emulator everything works fine. But if i create the client on the android emulator and the server on the pc, the client can not connect to the server (connection refused on address 127.0.0.1:(generic port)). I also tried to change the file hosts of the emulator (localhost from 127.0.0.1 to 10.0.2.2) but i received the same error.
Anyone know how to connect the client to the server? What IP address should i use?
Asked by denis on 2015-11-30 13:26:27 UTC
Comments
This could be caused by incorrect network configuration. The android emulator instances use a specific network setup, and iirc you'll need to change that, or at least keep it in mind.
Asked by gvdhoorn on 2015-12-01 03:26:14 UTC
Thanks a lot for the answer, but I'm not sure that is a network problem. If it was a network configuration problem, the app should not even connect with rosmaster. Instead the app connects to rosmaster normally.
Asked by denis on 2015-12-01 04:14:43 UTC
is your ros master also running on your PC? Or does the rosjava app start it? How is the ros master uri configured in your rosjava app? If it's set to
localhost
it should try to connect to thelocalhost
of the android device. It should be set to the IP of the host PC. Don't changelocalhost
.Asked by gvdhoorn on 2015-12-01 04:52:09 UTC
Master and server running on PC. Also the client, but using an emulator. Initially i start to run the master and the server. After this I start to run the client, then the client connects to the master using localhost(it works fine). The connection with server failed instead (also using localhost).
Asked by denis on 2015-12-01 05:26:10 UTC
How did you verify that the connection from client -> master is ok? Can you
rosnode ping ..
orrosnode info ..
the node on the android device?Asked by gvdhoorn on 2015-12-01 07:05:47 UTC
I cannot call these commands from the android device, but the connection between client and master is ok, I'm sure. If the connection between client and master fails the app stops the execution.
Asked by denis on 2015-12-01 08:26:41 UTC
I know you can't use those commands on the android device, but you can run them on the host, in a terminal. It would tell us if there are any basic networking issues.
Asked by gvdhoorn on 2015-12-01 08:32:06 UTC
If I run
rosnode list
from my desktop, I see all three nodes (client, server, master), everything works fine between the client try to connect the server. If I use the noderosnode info ..
i see all the nodes. But i cannot connect to client (because i cannot connect with the android device).Asked by denis on 2015-12-01 09:54:53 UTC
I tried to run the client application on a real android embedded device, but i received the same error (Connection refused). I connected the Client with the Master using a wifi connection, and it works. But after that the client tries to connect with the localhost and not the real server address.
Asked by denis on 2015-12-02 10:52:52 UTC
So what is the value of
ROS_MASTER_URI
on the client device? You should set it to the IP of the host that is running your ROS master. Also: make sure that your PC is reporting its IP and not its hostname, unless you have working DNS for your PC and android device.Asked by gvdhoorn on 2015-12-02 11:21:31 UTC
The
ROS_MASTER_URI
on the client device was correct? The problem wasROS_MASTER_URI
on the server, it was set to localhost. I corrected this error and now the application works correctly. Thanks a lot for your help!!Asked by denis on 2015-12-03 12:25:11 UTC
So just for my own understanding: what is not the value of
ROS_MASTER_URI
on the android device, and what is it on the PC?Asked by gvdhoorn on 2015-12-04 08:37:59 UTC
The problem was the
ROS_IP
variable of the Client, it was set tolocalhost
. But the client device has10.0.2.2
aslocalhost
(android emulator). So when I tried to contact the server, the connection failed because the system saw two different networks, although I used the same PC.Asked by denis on 2015-12-04 10:27:42 UTC