Open longduong11311 opened 4 years ago
You need to define the other two RosTextView in init. As per you code, I can only see that you define one.
add below lines in your init method
nodeMainExecutor.execute(rosPreArm, nodeConfiguration);
nodeMainExecutor.execute(rosBattery , nodeConfiguration);
nodeMainExecutor.execute(rosMode, nodeConfiguration);
I try get 3 Topic based on android_tutorial_pubsub instead of 1 topic is "/chatter". Purpose is get multiple Topic to display monitor telephone. But I have issue this unable to get data at the same time. i only get 1 topic. Help me! My code:
package org.ros.android.android_tutorial_pubsub; import android.os.Bundle; import org.ros.android.MessageCallable; import org.ros.android.RosActivity; import org.ros.android.view.RosTextView; import org.ros.node.ConnectedNode; import org.ros.node.NodeConfiguration; import org.ros.node.NodeMainExecutor; import org.ros.node.topic.Subscriber; import std_msgs.String;
/**
public class MainActivity extends RosActivity { // create private RosTextView rosPreArm;
private RosTextView rosBattery;
private RosTextView rosMode;
protected NodeMainExecutor nodeMainExecutor;
public MainActivity() { // The RosActivity constructor configures the notification title and ticker // messages. super("Pubsub Tutorial", "Pubsub Tutorial"); }
@SuppressWarnings("unchecked") @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);
}
@Override protected void init(NodeMainExecutor nodeEx) { nodeMainExecutor = nodeEx;
}
protected void Battery(){ NodeConfiguration nodeConfiguration1 = NodeConfiguration.newPublic(getRosHostname()); nodeConfiguration1.setMasterUri(getMasterUri()); nodeMainExecutor.execute(rosBattery, nodeConfiguration1); }
protected void Mode(){ NodeConfiguration nodeConfiguration2 = NodeConfiguration.newPublic(getRosHostname()); nodeConfiguration2.setMasterUri(getMasterUri()); nodeMainExecutor.execute(rosMode, nodeConfiguration2); } }
And, I have issue is get message like: In file msg have: StatusType.msg (string PreArm, string Battery, string Mode, string Armed) and multiple file like GPSType.msg, AttitudeType.msg, ..., created by me. I want to get message in android instead of get Topic. Help me!