android: how do i set ros hostname and master uri programatically inside code?
I want to set ros hostname and ros master uri inside the code manually.When i open ros activity in ros android it asks to enter ros master uri but i want to internally put the ros master uri inside code.
Asked by bhattarairazu on 2018-11-05 07:24:07 UTC
Answers
Hi @bhattarairazu,
Take a look at the code of RosActiviy class. There is a constructor that accepts a custom master URI. If you extend RosActivity and you call this custom URI constructor, the ROS activity should skip the call for the MasterChooser: https://github.com/rosjava/android_core/blob/7bdff28e404699909316121081973f64902d1ae7/android_10/src/org/ros/android/RosActivity.java#L168-L173.
Then, you can use getMasterURI
method in your activity to retrieve the address that you specified in the first place. Note that the master URI is not set in the node itself, but in the configuration you use to actually execute the node. You can take at the pubsub tutorial for reference: https://github.com/rosjava/android_core/blob/7bdff28e404699909316121081973f64902d1ae7/android_tutorial_pubsub/src/org/ros/android/android_tutorial_pubsub/MainActivity.java#L57-L72.
Hope it helps!
Asked by jubeira on 2018-11-05 07:54:19 UTC
Comments
Hello @jubeira, I tried setting uri in the constructor and as you said i use getMasterURI method as well but it shows illegallStateException error in android. My code looks like this:
public DefaultAdd() {
super("Defaults Adds", "Default Add",URI.create("http://192.168.0.108:11311"));
}
Asked by bhattarairazu on 2018-11-06 00:52:30 UTC
What is the cause of the error in the stack trace? Do you have a ROS master running in that URI when you start the app?
Asked by jubeira on 2018-11-06 07:27:08 UTC
Comments