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

How to check if ROS-Master is running from rosjava

asked 2011-07-17 01:54:38 -0500

binford3000 gravatar image

Im working on an android app which displays the camera image of the PR2. If the ROS-Master is running, everything works as expected. However, if the Master-Server is offline it tries to connect until android invokes OnPause(). Because Im shutting down the RosImageView-Node in OnPause, it crashes (I guess because the node never was active and cannot unregister from the Masterserver which is not online).

Of course I could just remove the image.shutdown() but I wonder if there is a clean way to check if the ROS-Master is online. Another thing Id like to know is if there is a way to specify a timeout for the connection attempt to the master server.

Im running the node like this:

NodeConfiguration nodeConfiguration = NodeConfiguration

Log.i("roboremote", "ROS node started");, nodeConfiguration);

and OnPause looks like this:

protected void onPause() {

    if (image != null) {
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2011-07-18 09:23:55 -0500

damonkohler gravatar image

updated 2011-07-18 09:24:18 -0500

I've run into this before. The problem is that startup and shutdown are asynchronous and can be executed simultaneously.

You can ask the node if it's registered via Node.isRegistered(). If that's true, then the master is up and responding.

The correct solution is probably to be smarter in Node.shutdown(). Please file an issue:

If possible, include any code to reproduce the issue.

edit flag offensive delete link more

Question Tools


Asked: 2011-07-17 01:54:38 -0500

Seen: 1,179 times

Last updated: Jul 18 '11