def _message_info_cb(self, req): package_message = tuple(req.type.split("/")) if not self.message_cache.has_key(package_message): rospy.loginfo("Loading module to return info on %s/%s." % package_message) msg = load_message(*package_message) self.message_cache[package_message] = (msg._md5sum, msg._full_text) else: rospy.loginfo("Returning info from cache on %s/%s." % package_message) return self.message_cache[package_message]
def _message_info_cb(self, req): package_message = tuple(req.type.split("/")) if not self.message_cache.has_key(package_message): rospy.loginfo("Loading module to return info on %s/%s." % package_message) msg = load_message(*package_message) if msg._full_text == "": # fix for "Advertising on topic [/topic_name] with an empty message definition. warning" # see https://github.com/ros/ros_comm/issues/344 msg._full_text = "\n" self.message_cache[package_message] = (msg._md5sum, msg._full_text) else: rospy.loginfo("Returning info from cache on %s/%s." % package_message) return self.message_cache[package_message]
def __init__(self, topic_info, parent): self.topic = topic_info.topic_name self.id = topic_info.topic_id self.parent = parent # find message type package, message = topic_info.message_type.split('/') self.message = load_message(package, message) if self.message._md5sum == topic_info.md5sum: queue_s=1 buff_s=65536 self.subscriber = rospy.Subscriber(self.topic, self.message, self.callback, callback_args=None, queue_size=queue_s, buff_size=buff_s, tcp_nodelay=False) rospy.loginfo('Init hSubscriber with queue_size: ' + str(queue_s) + ', buff_size: ' + str(buff_s)) else: raise Exception('Checksum does not match: ' + self.message._md5sum + ',' + topic_info.md5sum)
def initSerialNode(serial_node, node_data): debug = rospy.get_param('~debug', False); # To subscribe to atopic through rosserial means to create a local publisher that # forwards rosserial data to the local ROS network subscriber_list = rospy.get_param('~subscriber_list',[]) topic_idx = 0 for topic in subscriber_list: # only create topic if we are explicitly subscribing to this node # i.e topic['node_name'] == serial.node.node_data['node_id'] # or topic['node_name'] == 'broadcast' if debug: rospy.loginfo("Expected topic node_name [%s]. Discovered node name [%s]."%(topic['node_name'],node.node_data)) if topic['node_name'] != node_data['node_id'] or topic['node_name'] != 'broadcast': pass if debug: rospy.loginfo("Trying to create serial subscriber") topic_idx = topic_idx+1 msg = topic['type'] m = load_message(msg['package'],msg['name']) ti = TopicInfo() ti.topic_id=100+topic_idx ti.topic_name = topic['topic'] ti.message_type = "%s/%s"%(msg['package'],msg['name']) ti.md5sum = m._md5sum ti.buffer_size = 512 _buffer = StringIO.StringIO() ti.serialize(_buffer) serial_node.setupPublisher(_buffer.getvalue()) # To publish to a topic through rosserial means to create a local subscriber that # pushes ROS messages into the rosserial link publisher_list = rospy.get_param('~publisher_list',[]) for topic in publisher_list: # only create topic if we are explicitly publishing to this node # i.e topic['node_name'] == serial.node.node_data['node_id'] # or topic['node_name'] == 'broadcast' if debug: rospy.loginfo("Expected topic node_name [%s]. Discovered node name [%s]."%(topic['node_name'],node.node_data)) if topic['node_name'] != node_data['node_id'] or topic['node_name'] != 'broadcast': pass if debug: rospy.loginfo("Trying to create serial publisher") topic_idx = topic_idx+1 msg = topic['type'] m = load_message(msg['package'],msg['name']) ti = TopicInfo() ti.topic_id=200+topic_idx ti.topic_name = topic['topic'] ti.message_type = "%s/%s"%(msg['package'],msg['name']) ti.md5sum = m._md5sum ti.buffer_size = 512 _buffer = StringIO.StringIO() ti.serialize(_buffer) serial_node.setupSubscriber(_buffer.getvalue()) #service_client_list = rospy.get_param('~service_client_list',[]) #service_server_list = rospy.get_param('~service_server_list',[]) serial_node.negotiateTopics()