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

Revision history [back]

click to hide/show revision 1
initial version

You can use the old way they used to do things. I was also in the situation where I absolutely could not use RosActivity (since I was already extending).

The method I currently use is:

nodeConfiguration = NodeConfiguration
                        .newPublic(InetAddressFactory.newNonLoopback()
                                .getHostAddress());

String hostMaster = prefs.getString("ros_IP", "");
Integer port = Integer.parseInt(prefs.getString("ros_port",
                        ""));
URI uri = URI.create("http://" + hostMaster + ":" + port);
nodeConfiguration.setMasterUri(uri);

nodeMainExecutor = DefaultNodeMainExecutor.newDefault();
nodeMainExecutor.execute(vehSub, nodeConfiguration);

You can use the old way they used to do things. I was also in the situation where I absolutely could not use RosActivity (since I was already extending). I dug in to their ROSActivity and a few of their tutorials to find the below. Hope it helps.

The method I currently use is:

nodeConfiguration = NodeConfiguration
                        .newPublic(InetAddressFactory.newNonLoopback()
                                .getHostAddress());

String hostMaster = prefs.getString("ros_IP", "");
Integer port = Integer.parseInt(prefs.getString("ros_port",
                        ""));
URI uri = URI.create("http://" + hostMaster + ":" + port);
nodeConfiguration.setMasterUri(uri);

nodeMainExecutor = DefaultNodeMainExecutor.newDefault();
nodeMainExecutor.execute(vehSub, nodeMainExecutor.execute(<NAMEOFNODECLASS>, nodeConfiguration);

I am using a preference menu to hold the hostMaster IP and port, but you can change those directly.

I have been working with ROSJava a lot lately and have been looking for some people who may be more involved in it to hit questions back and forth. I hope this helps you.