0
$\begingroup$

Rosanswers logo

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 org.ros.internal.node.DefaultNode$5.run(DefaultNode.java:503)
at org.ros.concurrent.EventDispatcher.loop(EventDispatcher.java:43)
at org.ros.concurrent.CancellableLoop.run(CancellableLoop.java:56)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.nio.channels.UnresolvedAddressException
at java.nio.SocketChannelImpl.validateAddress(SocketChannelImpl.java:453)
at java.nio.SocketChannelImpl.connect(SocketChannelImpl.java:180)
at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink.connect(NioClientSocketPipelineSink.java:139)
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 org.ros.internal.node.DefaultNode$5.run(DefaultNode.java:503) 
at org.ros.concurrent.EventDispatcher.loop(EventDispatcher.java:43) 
at org.ros.concurrent.CancellableLoop.run(CancellableLoop.java:56) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)

Originally posted by al on ROS Answers with karma: 18 on 2016-09-01

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by al with karma: 18 on 2016-09-02

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by al on 2016-09-02:
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?

Comment by dambrosio on 2017-02-16:
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/03/build-rosjava-library-sources-in-ros-w-android-studio/

Comment by al on 2017-02-16:
thanks for the instructions. I will try to find time for that.

Comment by Will Chamberlain on 2017-02-19:
Hi @al - did you have any success with that - I have the same problem.

Comment by al on 2017-04-26:
Easier to set the environment variable ROS_IP in the PC

Read the following: http://wiki.ros.org/ROS/NetworkSetup#Name_resolution http://answers.ros.org/question/10826/rosjava-image_transport-tutorial-no-image-display-on-android-tablet-despite-successful-compilation/

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.