Ask Your Question
0

rosandroid tutorial_pubsub connection bewteen RosTextView and Talker-message

asked 2014-08-06 09:18:57 -0600

stefan gravatar image

In the talker the message is published

in the res/layout a rostextview is created

where is the link that makes the rostextview show the message?

Thanks

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-08-06 10:05:12 -0600

gvdhoorn gravatar image

updated 2014-08-06 10:09:29 -0600

Could you indicate what wasn't clear in the extended answer to your previous question?

If you want the actual source, see RosTextView.java in org.ros.android.view, lines 68 to 92 (this is the Hydro version):

public void onStart(ConnectedNode connectedNode) {
  Subscriber<T> subscriber = connectedNode.newSubscriber(topicName, messageType);
  subscriber.addMessageListener(new MessageListener<T>() {
    @Override
    public void onNewMessage(final T message) {
      if (callable != null) {
        post(new Runnable() {
          @Override
          public void run() {
            setText(callable.call(message));
          }
        });
      } else {
        post(new Runnable() {
          @Override
          public void run() {
            setText(message.toString());
          }
        });
      }
      postInvalidate();
    }
  });
}

The onNewMessage(..) method essentially calls the callback registered earlier by the user, which in the case of a std_msgs::String could just return the string itself.


Btw: you might be interested in the ROS Java Special Interest Group.

edit flag offensive delete link more

Comments

ok... :) ... i guess i lost sight of the wood for the trees yesterday - should have looked in my onCreate in the MainActivity - i added a whole lot of stuff in between meanwhile

stefan gravatar imagestefan ( 2014-08-07 01:42:18 -0600 )edit

So, question answered then?

gvdhoorn gravatar imagegvdhoorn ( 2014-08-07 10:13:49 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-08-06 09:18:57 -0600

Seen: 57 times

Last updated: Aug 06 '14