Exemplo n.º 1
0
    def publish(self, msg: MsgType) -> None:
        """
        Send a message to the topic for the publisher.

        :param msg: The ROS message to publish. The message must be the same type as the type
            provided when the publisher was constructed.
        """
        _rclpy.rclpy_publish(self.publisher_handle, msg)
Exemplo n.º 2
0
    def publish(self, msg: MsgType) -> None:
        """
        Send a message to the topic for the publisher.

        :param msg: The ROS message to publish.
        :raises: TypeError if the type of the passed message isn't an instance
          of the provided type when the publisher was constructed.
        """
        if not isinstance(msg, self.msg_type):
            raise TypeError()
        with self.handle as capsule:
            _rclpy.rclpy_publish(capsule, msg)
Exemplo n.º 3
0
    def publish(self, msg: Union[MsgType, bytes]) -> None:
        """
        Send a message to the topic for the publisher.

        :param msg: The ROS message to publish.
        :raises: TypeError if the type of the passed message isn't an instance
          of the provided type when the publisher was constructed.
        """
        with self.handle as capsule:
            if isinstance(msg, self.msg_type):
                _rclpy.rclpy_publish(capsule, msg)
            elif isinstance(msg, bytes):
                _rclpy.rclpy_publish_raw(capsule, msg)
            else:
                raise TypeError('Expected {}, got {}'.format(self.msg_type, type(msg)))
Exemplo n.º 4
0
 def publish(self, msg):
     _rclpy.rclpy_publish(self.publisher_handle, msg)
Exemplo n.º 5
0
 def publish(self, msg):
     _rclpy.rclpy_publish(self.publisher_handle, msg)