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

Revision history [back]

click to hide/show revision 1
initial version

You do not need to create nodes manually. Instead, build a class (for example, a View) that implements the NodeMain interface. In your activity's init(NodeMainExecutor nmExecutor) method, call

nmExecutor.execute(yourView, yourNodeConfig);

as shown on lines 48 and 51 of the example activity.

Your class should implement the methods from both NodeMain and NodeListener as shown in the rosjava documentation. You will receive the actual node object in your onStart(ConnectedNode node) method; you can add topic and service interactions there.

Note that you should NOT rely on onStart() running immediately; if you want to interact with the node from your activity (e.g., to call a service you have created), check to make sure the node has actually been created first.