在我的 android 应用程序中为自定义消息创建新订阅者时遇到问题。我在 java 项目中有相同的代码,并且可以在终端中显示信息消息。
错误日志是:
E/UpdatePublisherRunnable(4793): java.lang.RuntimeException: java.net.UnknownHostException: Unable to resolve host "arturo-desktop": No address associated with hostname
我以这种方式创建订阅者:
Subscriber<meta_msgs.NodesList> subscriber2 = connectedNode.newSubscriber("nodes_list", meta_msgs.NodesList._TYPE);
subscriber2.addMessageListener(new MessageListener<meta_msgs.NodesList>() {
@Override
public void onNewMessage(meta_msgs.NodesList message) {
Toast.makeText(getContext(), "OK. Message Received!!!", Toast.LENGTH_SHORT).show();
}
});
我的自定义消息也由自定义消息组成。以下是代码:
节点列表.msg:
Header header #for timestamp
NodeInfo[] nodes # an array of the nodes
节点信息.msg:
# This message holds info of a ROS node
#
# Possible levels of operations
byte OK=1
byte ERROR=0
string node_name # the name of the node
byte status # status of the ros node regarding master connectivity
ROSTopic[] subs
ROSTopic[] pubs
ROSParameter[] params # the parameters of the node
string[] errors # latest history of relevant messages sent to rosout from the node
ROSParameter.msg:
string type # see OMTypes.msg for values
string name
uint8[] value
ROSTopic.msg:
string name # name of the topic
string type # type of the message
OMTypes.msg:
# Python format characters are used to simplify the Python code
string INTEGER=i
string STRING=64p
string DOUBLE=d
有人在使用 Android 尝试自定义消息时遇到问题吗?谢谢!它对我来说非常重要!