def create_publisher( self, msg_type, topic: str, *, qos_profile: QoSProfile = qos_profile_default) -> Publisher: """ Create a new publisher. :param msg_type: The type of ROS messages the publisher will publish. :param topic: The name of the topic the publisher will publish to. :param qos_profile: The quality of service profile to apply to the publisher. :return: The new publisher. """ # this line imports the typesupport for the message module if not already done check_for_type_support(msg_type) failed = False try: with self.handle as node_capsule: publisher_capsule = _rclpy.rclpy_create_publisher( node_capsule, msg_type, topic, qos_profile.get_c_qos_profile()) except ValueError: failed = True if failed: self._validate_topic_or_service_name(topic) publisher_handle = Handle(publisher_capsule) publisher_handle.requires(self.handle) publisher = Publisher(publisher_handle, msg_type, topic, qos_profile) self.__publishers.append(publisher) return publisher
def create_publisher(self, msg_type, topic, qos_profile=qos_profile_default): # this line imports the typesupport for the message module if not already done if msg_type.__class__._TYPE_SUPPORT is None: msg_type.__class__.__import_type_support__() if msg_type.__class__._TYPE_SUPPORT is None: raise NoTypeSupportImportedException publisher_handle = _rclpy.rclpy_create_publisher( self.handle, msg_type, topic, qos_profile.get_c_qos_profile()) publisher = Publisher(publisher_handle, msg_type, topic, qos_profile, self.handle) self.publishers.append(publisher) return publisher
def create_publisher(self, msg_type, topic, *, qos_profile=qos_profile_default): # this line imports the typesupport for the message module if not already done check_for_type_support(msg_type) failed = False try: publisher_handle = _rclpy.rclpy_create_publisher( self.handle, msg_type, topic, qos_profile.get_c_qos_profile()) except ValueError: failed = True if failed: self._validate_topic_or_service_name(topic) publisher = Publisher(publisher_handle, msg_type, topic, qos_profile, self.handle) self.publishers.append(publisher) return publisher