Using Rosjava in Android, I execute 2 nodes but only one node connects at a time.
Hi,
I'm trying to create a rosandroid that will subscribe to get images and the other to publish Strings. I have created 2 classes:
RosImageViewPatched extends SurfaceView implements NodeMain
and
RemoconNode extends AbstractNodeMain
When I execute only one node with nodeMainExecutor. nodeMainExecutor.execute(imageNode, nodeConfiguration2); only it works
or
nodeMainExecutor.execute(controllerNode, nodeConfiguration2); only it works
but when I execute both like this
nodeMainExecutor.execute(imageNode, nodeConfiguration2); nodeMainExecutor.execute(controllerNode, nodeConfiguration2);
only the first one works.
when I try to execute with 2 separate nodeconfigurations like this
nodeMainExecutor.execute(imageNode, nodeConfiguration); nodeMainExecutor.execute(controllerNode, nodeConfiguration2);
only the first one works and i got a connection refused error for I guess the second one.
Below is the code for the init function of the mainactivity. I ultimately want both nodes to work. Thank you.
@Override protected void init(NodeMainExecutor nodeMainExecutor) { Log.e("11311", "Node init"); controllerNode = new RemoconNode(); NodeConfiguration nodeConfiguration2 = NodeConfiguration.newPublic(InetAddressFactory.newNonLoopback().getHostAddress().toString()); nodeConfiguration2.setMasterUri(getMasterUri()); //nodeMainExecutor.execute(controllerNode, nodeConfiguration2); //nodeMainExecutor.execute(imageNode, nodeConfiguration);
//NodeConfiguration nodeConfiguration = //NodeConfiguration.newPublic(InetAddressFactory.newNonLoopback().getHostAddress().toString());
//nodeConfiguration.setMasterUri(getMasterUri());
//nodeMainExecutor.execute(controllerNode, nodeConfiguration);
nodeMainExecutor.execute(imageNode, nodeConfiguration2);
Button testButton = (Button) findViewById(R.id.button1);
testButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.e("11311", "button clicked");
controllerNode.publishTest();
}
});
}
Asked by Damonzon on 2014-07-13 01:41:02 UTC
Answers
I could fix it. I just needed to set the node name in the nodeConfiguration as follows.
NodeConfiguration nodeConfiguration = NodeConfiguration.newPublic(InetAddressFactory.newNonLoopback().getHostAddress().toString());
nodeConfiguration.setMasterUri(getMasterUri());
nodeConfiguration.setNodeName("imageNode");// <--this fixed it
nodeMainExecutor.execute(imageNode, nodeConfiguration);
NodeConfiguration nodeConfiguration2 = NodeConfiguration.newPublic(InetAddressFactory.newNonLoopback().getHostAddress().toString());
nodeConfiguration2.setMasterUri(getMasterUri());
nodeConfiguration2.setNodeName("controllerNode"); // <--this fixed it
nodeMainExecutor.execute(controllerNode, nodeConfiguration2);
Asked by Damonzon on 2014-07-16 20:30:30 UTC
Comments