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

How would I take multiple values from a subscriber to output to RosTextViews?

asked 2019-06-27 09:22:10 -0500

AmanjotG gravatar image

So I'm making a Ros-Android App to get the gps position of the robot using the ublox gps package on the robot. I've got my RosTextViews set up for longitude, latitute, altitude and heading. So do I create multiple NodeConfigurations and execute each RosTextView or can this be done with just nodeMainExecutor?

public class MainActivity extends RosActivity {
private RosTextView<sensor_msgs.NavSatFix> latitudeTextView;
private TextView longitudeTextView;
private TextView headerTextView;
private TextView altitudeTextView;

protected MainActivity() {
    super("gpsPoseApp", "gpsPoseApp");

protected void onCreate(Bundle savedInstanceState) {
    latitudeTextView = findViewById(;
    longitudeTextView = findViewById(;
    altitudeTextView = findViewById(;
    headerTextView = findViewById(;

public void processSubscribers(){
    latitudeTextView.setMessageToStringCallable(new MessageCallable<String, NavSatFix>() {
        public String call(NavSatFix navSatFix) {
            return String.valueOf(navSatFix.getLatitude());

protected void init(NodeMainExecutor nodeMainExecutor) {

    NodeConfiguration nodeConfiguration = NodeConfiguration.newPublic(InetAddressFactory.newNonLoopback().getHostAddress());
    nodeMainExecutor.execute(latitudeTextView, nodeConfiguration);



edit retag flag offensive close merge delete


I'm not sure if I understand the question. The standard approach would be using one text view for each of them. You can use the same NodeConfiguration object AFAIK.

jubeira gravatar image jubeira  ( 2019-07-04 12:10:11 -0500 )edit

I've tried that way but the problem is that the callables are all strings. When I receive the navSatFix messages, they're doubles. I then convert them to string using either String.valueOf(navSatFix.getLatitude()) or Double.toString(navSatFix.getLatitude()). When I output to the RosTextView, I just get a blank box.

AmanjotG gravatar image AmanjotG  ( 2019-07-04 12:24:05 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2019-07-04 13:39:21 -0500

AmanjotG gravatar image

I solved the issue I was having. It was because of this:

E/UpdatePublisherRunnable: java.lang.RuntimeException: Unable to resolve host "amanjot-precision-3520": No address associated with hostname

Once I set the HOSTNAME, IP and URI explicitly, I was able to receive the messages and display them to the RosTextView.

edit flag offensive delete link more

answered 2019-07-04 12:32:07 -0500

jubeira gravatar image

updated 2019-07-04 13:11:35 -0500

Have you checked the standard pubsub tutorial?

From what I can see, you need to specify the message type to the ROS text view: Other than that, the message callable looks OK.

You could also use a single node that parses the whole NavSatFix message and builds a single string representation out of it.

EDIT: Yes, the problem probably is that the Android device is not solving the hostname. Try using ROS_IPenvironment variable on the publisher side. See and for reference.

edit flag offensive delete link more


I've done the first part and I still get a blank textview. Publishing data works fine from the app but subscribing to data doesn't work at all from the robot. I've even tried the listener way of subscribing by having another class that extends AbstractNodeMain and subscribes from there. From that class, I just get 0.0 instead of an actual latitude value.

Do you think it has anything to do with getting a java.lang.RuntimeException for not being able to resolve host "": No address associated with hostname even though the master uri is correctly set?

AmanjotG gravatar image AmanjotG  ( 2019-07-04 12:58:34 -0500 )edit

Question Tools

1 follower


Asked: 2019-06-27 09:22:10 -0500

Seen: 133 times

Last updated: Jul 04 '19