0
$\begingroup$

Rosanswers logo

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();
    }
}

Originally posted by binford3000 on ROS Answers with karma: 21 on 2011-07-17

Post score: 2

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by damonkohler with karma: 3838 on 2011-07-18

This answer was ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

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