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

two nodes on ros android

asked 2015-04-27 09:26:18 -0600

zior89 gravatar image

Hello!

Do you know how can I run two nodes en a same activity on android?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-12-04 11:52:05 -0600

jubeira gravatar image

You can run any number of nodes within an activity. Simply do something like this (assuming your activity is a RosActivity):

@Override
protected void init(NodeMainExecutor nodeMainExecutor) {
    NodeConfiguration nodeConfiguration = NodeConfiguration.newPublic(getRosHostname());
    nodeConfiguration.setMasterUri(getMasterUri());

    nodeConfiguration.setNodeName("node_1");
    MyNode myNode1 = new MyNode();     // Something that extends AbstractNodeMain
    nodeMainExecutor.execute(myNode1, nodeConfiguration);

    nodeConfiguration.setNodeName("node_2");
    MyNode myNode2 = new MyNode();
    nodeMainExecutor.execute(myNode2, nodeConfiguration);     // And so on...
}
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-04-27 09:26:18 -0600

Seen: 216 times

Last updated: Dec 04 '17