#!/usr/bin/env python

import rospy
from cv_bridge import CvBridge
from cv2 import imread
from sensor_msgs.msg import Image


class ImageLatchedPublisher:

    def __init__(self):
        self._cv_bridge = CvBridge()
        self._filename = rospy.get_param('~file', 'image.jpg')
        self._pub = rospy.Publisher('image', Image,
                                    latch=True, queue_size=1)

    def spin(self):
        img = imread(self._filename)
        msg = self._cv_bridge.cv2_to_imgmsg(img, 'bgr8')
        self._pub.publish(msg)
        rospy.spin()


rospy.init_node('image_latch_publisher', anonymous=True)
ilp = ImageLatchedPublisher()
ilp.spin()


@@ -273,16 +273,66 @@
 e.jpg')%0A
+        self._rate = rospy.get_param('~rate', -1)%0A
         
@@ -435,16 +435,17 @@
 e_size=1
+0
 )%0A%0A    d
@@ -553,24 +553,25 @@
 'bgr8')%0A
+%0A
         
 self._pu
@@ -566,31 +566,228 @@
     
-self._pub.publish(msg)%0A
+if self._rate %3E 0:%0A            r = rospy.Rate(self._rate)%0A%0A            while not rospy.is_shutdown():%0A                self._pub.publish(msg)%0A                r.sleep()%0A        else:%0A            self._pub.publish(msg)%0A    
     

support a rate to republish image