Ask Your Question

ROSJava, Android_core, and nodes connecting to External Master

asked 2012-09-09 07:40:07 -0500

orion gravatar image

I am using ROSJava along with Android_core to allow multiple subscribers, publishers, and clients to connect to an external master. My application is not using ROSActivity due to the fact that I need to extend other classes in my various class files. I am mulling over the idea of using a ROSActivity class at some point, but until then, I am trying to find a way to confirm that the nodes have connected to the master correctly.

When I click a button on my android application, it attempts to connect and execute my various subscribers/etc. This is done by setting up nodeMainExecutor and nodeConfiguation, followed by an execute on the component in question. All of this works fine as long as the master (on the other computer) is up.

I need the ability to confirm that the node is up and to give some sort of feedback, however, I do not know what function/class to use or call to find this out. I do see that something is timing out in the background due to logcat giving me a timeout exception.

First, does anyone know of such a function or class to get this feedback? Second, does ROSActivity do this automatically, or would I have to do it there too? Thanks for any help.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2012-09-12 03:22:07 -0500

damonkohler gravatar image

The onStart() method of a NodeMain will be called when the node comes online. That should be where your business logic starts. See the rosjava docs:

Also, I would _strongly_ suggest extending RosActivity and using composition instead of inheritance for the other common functionality you're sharing between activities.

edit flag offensive delete link more


First, I have put thought into using composition, however, my main activity must extend MapActivity so I cannot extend RosActivity there. As for onStart(), I did see this and I have my publisher/subscriber here, but I didn't know if I should use a flag in there to be set when onStart is successful.

orion gravatar image orion  ( 2012-09-12 14:23:13 -0500 )edit

If you'd like to know when onStart has been called, a CountDownLatch may be possible. However, I suggest thinking more asynchronously and simply executing any code that would wait on the CountDownLatch from onStart.

damonkohler gravatar image damonkohler  ( 2012-09-13 22:45:33 -0500 )edit

Thanks, but it is simpler than that. I simply wanted to allow feedback for a user to know when the application was able to connect to the master. I do have all of the code in the onStart function and planned on putting my feedback there. I just wondered if nodeMainExecutor had something built in.

orion gravatar image orion  ( 2012-09-16 07:31:03 -0500 )edit

I'm sorry, I don't think I understand the problem. You could display a notification in onStart() in that case.

damonkohler gravatar image damonkohler  ( 2012-10-10 05:18:34 -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


Asked: 2012-09-09 07:40:07 -0500

Seen: 1,189 times

Last updated: Sep 12 '12