Ask Your Question
0

Using Rosjava in Android, I execute 2 nodes but only one node connects at a time.

asked 2014-07-13 01:41:02 -0500

Damonzon gravatar image

updated 2014-07-16 04:49:54 -0500

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();
        }
    });
}
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-07-16 20:30:30 -0500

Damonzon gravatar image

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);
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-07-13 01:41:02 -0500

Seen: 1,216 times

Last updated: Jul 16 '14