Ask Your Question
2

How to check if ROS-Master is running from rosjava

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

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
        .createDefault();
nodeConfiguration.setMasterUri(masterUri);
nodeConfiguration.setHost(InetAddressFactory.createNonLoopback()
        .getHostAddress());

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

nodeRunner.run(image, nodeConfiguration);

and OnPause looks like this:

protected void onPause() {
    super.onPause();

    if (image != null) {
        image.shutdown();
    }
}
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

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

damonkohler gravatar image

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

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: http://code.google.com/p/rosjava/issues/list

If possible, include any code to reproduce the issue.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

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

Seen: 699 times

Last updated: Jul 18 '11