ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
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.
2 | No.2 Revision |
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.