当前位置: 首页>>代码示例>>Python>>正文


Python ServerProxy.requestTopic方法代码示例

本文整理汇总了Python中xmlrpclib.ServerProxy.requestTopic方法的典型用法代码示例。如果您正苦于以下问题:Python ServerProxy.requestTopic方法的具体用法?Python ServerProxy.requestTopic怎么用?Python ServerProxy.requestTopic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在xmlrpclib.ServerProxy的用法示例。


在下文中一共展示了ServerProxy.requestTopic方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: requestTopic

# 需要导入模块: from xmlrpclib import ServerProxy [as 别名]
# 或者: from xmlrpclib.ServerProxy import requestTopic [as 别名]
 def requestTopic(self, topic):
     code, statusMessage, publishers = self.master.registerSubscriber(
         self.callerId, topic, lookupTopicType(topic)[0], self.callerApi
     )
     assert code == 1, (code, statusMessage)
     assert len(publishers) == 1, (topic, publishers)  # i.e. fails if publisher is not ready now
     print publishers
     publisher = ServerProxy(publishers[0])
     code, statusMessage, protocolParams = publisher.requestTopic(self.callerId, topic, [["TCPROS"]])
     assert code == 1, (code, statusMessage)
     assert len(protocolParams) == 3, protocolParams
     print code, statusMessage, protocolParams
     hostPortPair = (protocolParams[1], protocolParams[2])
     soc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)  # TCP
     soc.connect(hostPortPair)
     soc.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
     soc.setblocking(0)
     soc.settimeout(SOCKET_TIMEOUT)
     header = prefix4BytesLen(
         prefix4BytesLen("callerid=" + self.callerId)
         + prefix4BytesLen("topic=" + topic)
         + prefix4BytesLen("type=" + lookupTopicType(topic)[0])
         + prefix4BytesLen("md5sum=" + lookupTopicType(topic)[1])
         + ""
     )
     soc.send(header)
     return soc
开发者ID:robotika,项目名称:husky,代码行数:29,代码来源:node.py

示例2: len

# 需要导入模块: from xmlrpclib import ServerProxy [as 别名]
# 或者: from xmlrpclib.ServerProxy import requestTopic [as 别名]
code, statusMessage, topicTypes = master.getTopicTypes(caller_id)
assert code == 1, code
print "---"
print "topicTypes:"
for t in topicTypes:
    print t
print "---"

code, statusMessage, publishers = master.registerSubscriber(caller_id, topic, topic_type, caller_api)
assert code == 1, code
assert len(publishers) == 1, publishers  # i.e. fails if publisher is not ready now

print publishers
publisher = ServerProxy(publishers[0].replace("martind-ThinkPad-R60", "192.168.0.13"))  # "pseudo DNS"
code, statusMessage, protocolParams = publisher.requestTopic(caller_id, topic, [["TCPROS"]])
assert code == 1, code
assert len(protocolParams) == 3, protocolParams
print code, statusMessage, protocolParams

print protocolParams
# hostPortPair = ( "192.168.0.13", protocolParams[2] )
hostPortPair = (protocolParams[1], protocolParams[2])
soc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)  # TCP


soc.connect(hostPortPair)
soc.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
soc.setblocking(0)

soc.settimeout(3.0)
开发者ID:robotika,项目名称:husky,代码行数:32,代码来源:hello.py

示例3: ServerProxy

# 需要导入模块: from xmlrpclib import ServerProxy [as 别名]
# 或者: from xmlrpclib.ServerProxy import requestTopic [as 别名]
roslib.load_manifest("ros_monitor")
import os, sys
import rospy
from xmlrpclib import ServerProxy
import rosgraph

target_node = sys.argv[1]

rospy.init_node("introspecter", anonymous=True)

my_caller_id = rospy.get_name()
print "Caller ID: %s" % my_caller_id

# ask the master for this node's API URI
master = rosgraph.Master(my_caller_id)
node_api_uri = master.lookupNode(target_node)
print "Node URI: %s" % node_api_uri

# connect to the node and ask what it pubishes
ps = ServerProxy(node_api_uri)
(code, status_msg, topic_list) = ps.getPublications(my_caller_id)
print "=== Topics:"
print topic_list


# try to subscribe to each topic
for topic_name, topic_type in topic_list:
    print "Subscribing to topic %s with type %s" % (topic_name, topic_type)
    (code, status_msg, protocol_params) = ps.requestTopic(my_caller_id, topic_name, [["TCPROS"]])
    print protocol_params
开发者ID:jonbinney,项目名称:ros_monitor,代码行数:32,代码来源:introspect_graph.py


注:本文中的xmlrpclib.ServerProxy.requestTopic方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。