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

rosjava(android) pubsub tutorial

asked 2011-06-23 02:00:59 -0500

hughie gravatar image

I build rosjava pubsub tutorial without error. and I can run the PubSubTutorial on the AVD. It seems working well. but I don't know it is actually publishing the topic.

I ran the roscore in ubuntu PC, but PubSubTutorial is not trying to connect to roscore in PC. MainActivity Manifest has internet permission.

<uses-permission android:name="android.permission.INTERNET"></uses-permission>

Should I run the roscore(rosjava)? the DEFAULT_MASTER_URI is "http://localhost:11311/" was configured by NodeRunner.createDefault() function.

[2011-06-23 22:41:19 - MainActivity] Android Launch!
[2011-06-23 22:41:19 - MainActivity] adb is running normally.
[2011-06-23 22:41:19 - MainActivity] Performing org.ros.tutorials.pubsub.MainActivity activity launch
[2011-06-23 22:41:19 - MainActivity] Automatic Target Mode: using existing emulator 'emulator-5554' running compatible AVD 'scv'
[2011-06-23 22:41:21 - MainActivity] Application already deployed. No need to reinstall.
[2011-06-23 22:41:21 - MainActivity] Starting activity org.ros.tutorials.pubsub.MainActivity on device emulator-5554
[2011-06-23 22:41:22 - MainActivity] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=org.ros.tutorials.pubsub/.MainActivity }

How can I use this tutorial? Please give me a answer. Thank you.

edit retag flag offensive close merge delete

Comments

Could you clarify your question? You say that it built and runs fine on the AVD. Your logcat looks fine as well.
damonkohler gravatar image damonkohler  ( 2011-06-23 06:30:18 -0500 )edit

5 Answers

Sort by ยป oldest newest most voted
1

answered 2011-06-27 06:46:18 -0500

damonkohler gravatar image

To connect to a roscore that is running in an AVD, you'll need to use adb forwarding. See http://developer.android.com/guide/developing/tools/adb.html#forwardports

For example:

adb forward tcp:11311 tcp:11311

That will forward all TCP connections to port 11311 on your host to your AVD on port 11311.

edit flag offensive delete link more
0

answered 2011-06-29 01:28:49 -0500

damonkohler gravatar image

Those look like two different problems. In the first case, you successfully connected but tried to call a method (getSystemState) that is not implemented yet.

In the second case, I assume you're having network trouble.

edit flag offensive delete link more

Comments

Hi Damon, how do you the problem on the getSystemState be tackled, since it is not implemented. I still could not make the pubsub link with the development machine yet after numerous tries. Just a quick check, the pubsub tutorial (android) is actually setting up its own RosCore, isn't it?
soetommy gravatar image soetommy  ( 2011-07-06 04:37:32 -0500 )edit
And to follow up with the previous comment and the thread, if the pubsub tutorial is really setting up its own RosCore, how can we set it up so that it connects the roscore which is already running on the development pc? Thanks a lot!
soetommy gravatar image soetommy  ( 2011-07-06 04:38:57 -0500 )edit
0

answered 2011-06-28 01:19:46 -0500

hughie gravatar image

updated 2011-06-28 01:24:15 -0500

I tried [adb forward tcp:11311 tcp:11311] for connection with roscore in AVD. and [rostopic list] gave erros as below.

Traceback (most recent call last):
  File "/opt/ros_dia/ros/bin/rostopic", line 45, in <module>
    rostopic.rostopicmain()
  File "/opt/ros_dia/ros_comm/tools/rostopic/src/rostopic.py", line 1706, in rostopicmain
    _rostopic_cmd_list(argv)
  File "/opt/ros_dia/ros_comm/tools/rostopic/src/rostopic.py", line 1648, in _rostopic_cmd_list
    exitval = _rostopic_list(topic, verbose=options.verbose, subscribers_only=options.subscribers, publishers_only=options.publishers, group_by_host=options.hostname) or 0
  File "/opt/ros_dia/ros_comm/tools/rostopic/src/rostopic.py", line 873, in _rostopic_list
    state = master.getSystemState()
  File "/opt/ros_dia/ros_comm/tools/rosgraph/src/rosgraph/masterapi.py", line 467, in getSystemState
    return self._succeed(self.handle.getSystemState(self.caller_id))
  File "/usr/lib/python2.6/xmlrpclib.py", line 1199, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python2.6/xmlrpclib.py", line 1489, in __request
    verbose=self.__verbose
  File "/usr/lib/python2.6/xmlrpclib.py", line 1253, in request
    return self._parse_response(h.getfile(), sock)
  File "/usr/lib/python2.6/xmlrpclib.py", line 1392, in _parse_response
    return u.close()
  File "/usr/lib/python2.6/xmlrpclib.py", line 838, in close
    raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault 0: 'Failed to invoke method getSystemState in class org.ros.internal.node.xmlrpc.MasterImpl: null'>
hughie@hughie-nest:/opt/android-sdk-linux_x86/platform-tools$ rostopic list
Traceback (most recent call last):
  File "/opt/ros_dia/ros/bin/rostopic", line 45, in <module>
    rostopic.rostopicmain()
  File "/opt/ros_dia/ros_comm/tools/rostopic/src/rostopic.py", line 1706, in rostopicmain
    _rostopic_cmd_list(argv)
  File "/opt/ros_dia/ros_comm/tools/rostopic/src/rostopic.py", line 1648, in _rostopic_cmd_list
    exitval = _rostopic_list(topic, verbose=options.verbose, subscribers_only=options.subscribers, publishers_only=options.publishers, group_by_host=options.hostname) or 0
  File "/opt/ros_dia/ros_comm/tools/rostopic/src/rostopic.py", line 873, in _rostopic_list
    state = master.getSystemState()
  File "/opt/ros_dia/ros_comm/tools/rosgraph/src/rosgraph/masterapi.py", line 467, in getSystemState
    return self._succeed(self.handle.getSystemState(self.caller_id))
  File "/usr/lib/python2.6/xmlrpclib.py", line 1199, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python2.6/xmlrpclib.py", line 1489, in __request
    verbose=self.__verbose
  File "/usr/lib/python2.6/xmlrpclib.py", line 1253, in request
    return self._parse_response(h.getfile(), sock)
  File "/usr/lib/python2.6/xmlrpclib.py", line 1392, in _parse_response
    return u.close()
  File "/usr/lib/python2.6/xmlrpclib.py", line 838, in close
    raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault 0: 'Failed to invoke method getSystemState in class org.ros.internal.node.xmlrpc.MasterImpl: null'>

my rosjava listener also can not connect to roscre in AVD.

Jun 28, 2011 10:21:07 PM org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
INFO: I/O exception (java.net.ConnectException) caught when processing request: Connection refused
Jun 28, 2011 10:21:07 PM org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
INFO: Retrying request
edit flag offensive delete link more

Comments

Please edit your question instead of providing more details in an answer field. They can and will be reordered. This isn't a forum.
tfoote gravatar image tfoote  ( 2011-07-02 05:54:46 -0500 )edit
0

answered 2011-06-23 12:04:43 -0500

hughie gravatar image

Thanks for answer, damonkohler. Sorry, I'm not good at speaking english. Maybe, is roscore running in AVD? and If I want to receive published message from PubSubTutorial, then should I make another listener app for avd?

If roscore is running in AVD, can I connect from PC by rostopic utility?

edit flag offensive delete link more

Comments

For future reference, you probably should have written this as a comment in reply to my comment.
damonkohler gravatar image damonkohler  ( 2011-06-27 06:44:15 -0500 )edit
0

answered 2011-07-15 07:21:40 -0500

ICodeRaven gravatar image

I don't know if this helps, but we run our roscore on a separate machine on the network. The issue was that nodes generated were trying to refer to localhost, which is obviously not defined for an external node trying to connect to the roscore.

To accomplish this, in the main activity class file edit the following code

rosCore = RosCore.createPublic(11311); nodeConfiguration.setMasterUri(rosCore.getUri());

to be

rosCore = RosCore.createPublic("* . * . * . * ",11311); nodeConfiguration.setMasterUri(new URI("http://*.edu:11311"));

where * . * . * . * is the IP address of the android device on the network (e.g. WiFi?). This can be replaced by a request for the current IP, eliminating the need for a static IP address. Instead of a static IP address you could also use InetAddressFactory.createNonLoopback().getHostAddress() to generate a non loopback address, which does a better job.

What the first line does is that it assigns the nodes to run on the local Android IP address which can be resolved by a rostopic command running on the network rather than the default localhost which cannot be resolved by an external rostopic, giving XML-RPC errors in the process.

Hope that helps someone.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2011-06-23 02:00:59 -0500

Seen: 2,228 times

Last updated: Jul 15 '11