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

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

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

Damonzon gravatar image

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


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


RemoconNode extends AbstractNodeMain

When I execute only one node with nodeMainExecutor. nodeMainExecutor.execute(imageNode, nodeConfiguration2); only it works


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());
    //nodeMainExecutor.execute(controllerNode, nodeConfiguration);
    nodeMainExecutor.execute(imageNode, nodeConfiguration2);

    Button testButton = (Button) findViewById(;
    testButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Log.e("11311", "button clicked");
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

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

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.setNodeName("imageNode");// <--this fixed it
    nodeMainExecutor.execute(imageNode, nodeConfiguration);

    NodeConfiguration nodeConfiguration2 = NodeConfiguration.newPublic(InetAddressFactory.newNonLoopback().getHostAddress().toString());
    nodeConfiguration2.setNodeName("controllerNode"); // <--this fixed it
    nodeMainExecutor.execute(controllerNode, nodeConfiguration2);
edit flag offensive delete link more

Question Tools

1 follower


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

Seen: 1,363 times

Last updated: Jul 16 '14