rosjava / android_core

Android libraries for rosjava
145 stars 166 forks source link

Add functionality to bypass the MasterChooserActivity #233

Closed rking788 closed 9 years ago

rking788 commented 9 years ago

It may not always be necessary to present the MasterChooserActivity. This change allows the MasterURI to be specified via the RosActivity constructor. If none is provided, it will fallback to presenting the MasterChooser.

stonier commented 9 years ago

This is a nice idea that we've wanted for a while, been using workarounds instead...I'll have a look at it shortly.

rking788 commented 9 years ago

Sounds good. Thanks.

stonier commented 9 years ago

No problems here. :neckbeard:

stonier commented 9 years ago

@Rking788 Could you write a brief tutorial on the RosActivity with a reference about the chooser/no chooser? Tutorial would go here. I'll redirect that information into android_core's sphinx api documentation once I've updated it for indigo (#234).

rking788 commented 9 years ago

Thanks for merging in those changes @stonier. Here is the requested wiki write-up

To Choose or Not to Choose?

There is now an optional way of bypassing the MasterChooser activity in android_core by providing a master URI to the RosActivity constructor.

The Master Chooser

Bundled into android_core is an Activity subclass named MasterChooser. This activity can be used to specify an existing ROS master node or start a new master node on the device. This activity is created and presented in the RosActivity constructor. The view for the MasterChooser contains an EditText field for entering the master node URI as well as a button to connect to the node. There are also some advanced options that can be used when creating a new master node on the device.

It is important to note that the MasterChooser needs to be declared in the application's manifest to avoid a crash. This can be done by adding the following line inside the tag.

<activity android:name="org.ros.android.MasterChooser" />

Avoiding the Master Chooser

There are cases where the master node URI can either be hardcoded into the application or it would be best to present a custom view for specifying the master node. This can be accomplished by providing a custom URI in the call to the RosActivity constructor. This will allow the application to use a RosActivity without presenting the MasterChooser.

As an example, to bypass the MasterChooser, the following code from the android_tutorial_pubsub MainActivity:

super("Pubsub Tutorial", "Pubsub Tutorial");

would be changed to something similar to:

super("Pubsub Tutorial", "Pubsub Tutorial", URI.create("http://localhost:11311"));
stonier commented 9 years ago

Awesome, can you add this to the wiki tutorial?