How would I take multiple values from a subscriber to output to RosTextViews?
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");
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
latitudeTextView = findViewById(R.id.latitudeTxtView);
longitudeTextView = findViewById(R.id.longitudeTxtView);
altitudeTextView = findViewById(R.id.altitudeTxtView);
headerTextView = findViewById(R.id.headerTextView);
processSubscribers();
}
public void processSubscribers(){
latitudeTextView.setTopicName("/ublox_gps_node/fix");
latitudeTextView.setMessageToStringCallable(new MessageCallable<String, NavSatFix>() {
@Override
public String call(NavSatFix navSatFix) {
return String.valueOf(navSatFix.getLatitude());
}
});
}
@Override
protected void init(NodeMainExecutor nodeMainExecutor) {
NodeConfiguration nodeConfiguration = NodeConfiguration.newPublic(InetAddressFactory.newNonLoopback().getHostAddress());
nodeConfiguration.setMasterUri(getMasterUri());
nodeMainExecutor.execute(latitudeTextView, nodeConfiguration);
}
}
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.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.