Rosanswers logo

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.

Originally posted by orion on ROS Answers with karma: 213 on 2012-09-09

Post score: 0


1 Answer 1


Rosanswers logo

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.

Originally posted by damonkohler with karma: 3838 on 2012-09-12

This answer was ACCEPTED on the original site

Post score: 1

Original comments

Comment by orion on 2012-09-12:
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.

Comment by damonkohler on 2012-09-13:
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.

Comment by orion on 2012-09-16:
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.

Comment by damonkohler on 2012-10-10:
I'm sorry, I don't think I understand the problem. You could display a notification in onStart() in that case.


Your Answer

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