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

Revision history [back]

The easiest way to run a RosMain instance in a thread is to use the NodeRunner class.

NodeConfiguration nodeConfiguration =
        NodeConfiguration.newPublic(InetAddressFactory.newNonLoopback().getHostName(),
                getMasterUri());
FooNodeMain foo = new FooNodeMain();
DefaultNodeRunner.newDefault().run(foo, nodeConfiguration);

In the above example, the class FooNodeMain needs to implement org.ros.node.NodeMain. NodeRunner's run method is non-blocking and just runs your node in a new thread.

The easiest way to run a RosMain instance in a thread is to use the NodeRunner class.

NodeConfiguration nodeConfiguration =
        NodeConfiguration.newPublic(InetAddressFactory.newNonLoopback().getHostName(),
                getMasterUri());
FooNodeMain foo = new FooNodeMain();
DefaultNodeRunner.newDefault().run(foo, nodeConfiguration);

In the above example, the class FooNodeMain needs to implement org.ros.node.NodeMain. NodeRunner's run method is non-blocking and just runs your node in a new thread.thread and you can call it multiple times to spawn different nodes.