Ask Your Question
0

unresolved address when instantiating a service client on rosjava android

asked 2016-09-01 11:00:53 -0500

al gravatar image

updated 2016-09-01 12:22:11 -0500

gvdhoorn gravatar image

Hi,

I have roscore and turtlesim_node on an ubuntu running in virtualbox under windows10, and a rosjava android app. The android app is starting correctly, finding the master. I can see the ros graph correctly from the linux computer.

Then I have added in the rosjava-android node the creation of a serviceclient to change the request the turtlesim_node to change the position of the turtle by invoking the service /turtle1/teleport_absolute. On the linux computer, the roscore and the turtlesim_node are running up.

In my android node, the code is like this:

...
public void onStart(final ConnectedNode connectedNode) {
        try {
            Log.d("BLAH", "ServiceCLient... creating serviceclient!");
            serviceClient = connectedNode.newServiceClient("/turtle1/teleport_absolute", TeleportAbsolute._TYPE);
            Thread.sleep(100);
            Log.d("BLAH", "ServiceCLient CREATED!"); // this is never reached
        } catch (ServiceNotFoundException e) {
            Log.d("BLAH", "ServiceCLient FAILED!"); // the exception thrown is not of this kind...
            throw new RosRuntimeException(e);
        }
        catch (Exception ex){
            Log.d("BLAH", "ServiceCLient Definitively FAILED!"); // so this will catch the exception to avoid crashing the app
        }
...

it fails when creating the serviceclient. The stacktrace looks like the one below.

Apparently, the android node cannot reach the master when creating a serviceclient. But a call to getRosHostname() and getMasterUri() in the init() method of my rosactivity confirms that the IPs are correct, and I can see the graph and the list of nodes and services on the linux computer with no problem.

Moreover, Ping commands in both computers (linux and android) are successful when IPs are used. I cannot resolve by name.

I wonder what I am missing, and whether rosjava is taking a name instead of a ip when creating a serviceclient, causing this issue due to using a virtualized linux.

Any help will be very useful.

Stacktrace:

com.my.sample1rosapp W/DefaultChannelPipeline: An exception was thrown by a user handler while handling an exception event ([id: 0x14cf6630] EXCEPTION: java.nio.channels.UnresolvedAddressException)                                                                                                org.ros.exception.RosRuntimeException: java.nio.channels.UnresolvedAddressException
at org.ros.internal.transport.ConnectionTrackingHandler.exceptionCaught(ConnectionTrackingHandler.java:81)
at org.jboss.netty.channel.Channels.fireExceptionCaught(Channels.java:533)
at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink.connect(NioClientSocketPipelineSink.java:157)
at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink.eventSunk(NioClientSocketPipelineSink.java:102)
at org.jboss.netty.handler.codec.oneone.OneToOneEncoder.handleDownstream(OneToOneEncoder.java:55)
at org.jboss.netty.channel.Channels.connect(Channels.java:642)
at org.jboss.netty.channel.AbstractChannel.connect(AbstractChannel.java:205)
at org.jboss.netty.bootstrap.ClientBootstrap.connect(ClientBootstrap.java:230)
at org.jboss.netty.bootstrap.ClientBootstrap.connect(ClientBootstrap.java:183)
at org.ros.internal.transport.tcp.TcpClient.connect(TcpClient.java:101)
at org.ros.internal.transport.tcp.TcpClientManager.connect(TcpClientManager.java:69)
at org.ros.internal.node.service.DefaultServiceClient.connect(DefaultServiceClient.java:137)
at org.ros.internal.node.service.ServiceFactory.newClient(ServiceFactory.java:146)
at org.ros.internal.node.DefaultNode.newServiceClient(DefaultNode.java:365)
at org.ros.internal.node.DefaultNode.newServiceClient(DefaultNode.java:372)
at com.my.sample1rosapp.ExampleNode.onStart(ExampleNode.java:44)
at org.ros.internal.node.DefaultNode$5.run(DefaultNode.java:506)
at ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-09-02 09:34:06 -0500

al gravatar image

I tested a few more things. I created a rosjava node running directly on windows/jvm. I got the same issue, like in the rosjava node running in android.

The serviceclient is using the name of the host where the ros master is running instead of the ip. So the temporal solution is to edit the hosts file of the system, so that it can resolve it by name.

edit flag offensive delete link more

Comments

I have also tested with the ros master and the turtlesim running in ubuntu natively (without virtualbox). I needed to set the hosts file in windows too. So the issue is more with the network configuration in all the computing nodes so that they can find each other by name. any suggestion to config?

al gravatar imageal ( 2016-09-02 11:21:11 -0500 )edit

Al, If you find this issue in the rosjava source code, you can update the source to use IP instead of host and then rebuild the source. Here are instructions on rebuilding from source. http://www.stratom.com/blog/2016/03/0...

dambrosio gravatar imagedambrosio ( 2017-02-16 10:03:44 -0500 )edit

thanks for the instructions. I will try to find time for that.

al gravatar imageal ( 2017-02-16 11:25:49 -0500 )edit

Hi @al - did you have any success with that - I have the same problem.

Will Chamberlain gravatar imageWill Chamberlain ( 2017-02-19 21:54:18 -0500 )edit

Easier to set the environment variable ROS_IP in the PC

Read the following: http://wiki.ros.org/ROS/NetworkSetup#...http://answers.ros.org/question/10826...

al gravatar imageal ( 2017-04-26 11:20:58 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-09-01 11:00:53 -0500

Seen: 481 times

Last updated: Sep 02 '16