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

Sending ROS Nodes between Android Activities

asked 2012-05-08 10:49:04 -0600

Srogacki gravatar image

I have a ROS node that I want to be able to communicate with from a view class in an android app. This view class is outside of the mainActivity. At present, I believe that I must either:

  1. create the node in the mainActivity and then send it, or a pointer to it, down a line of activities to the view that will communicate with it.
  2. create the node in the view class that will directly communicate with it.

I believe that, with the second option, I will need to send either the nodeMainExecutor or a reference to it.

Any help or comments would be appreciated.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2012-05-15 08:46:26 -0600

jatowler gravatar image

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.

edit flag offensive delete link more
1

answered 2012-05-10 05:40:21 -0600

damonkohler gravatar image

Views should implement NodeMain and be executed by the NodeMainExecutor. See the android_tutorial_pubsub for an example and the android_core documentation: http://docs.rosjava.googlecode.com/hg/android_core/html/index.html

edit flag offensive delete link more

Question Tools

Stats

Asked: 2012-05-08 10:49:04 -0600

Seen: 387 times

Last updated: May 15 '12