]> defiant.homedns.org Git - ros_wild_thumper.git/blob - scripts/imagefeed.py
amcl: increase translation error
[ros_wild_thumper.git] / scripts / imagefeed.py
1 #!/usr/bin/env python
2 # Lucas Walter
3 # GNU GPLv3
4 # Load an image from disk and publish it repeatedly
5
6 import cv2
7 import numpy as np
8 import rospy
9 import sys
10 from sensor_msgs.msg import Image
11
12 if __name__ == '__main__': 
13     rospy.init_node('image_publish')
14
15     name = sys.argv[1]
16     image = cv2.imread(name)
17     #cv2.imshow("im", image)
18     #cv2.waitKey(5)
19
20     hz = rospy.get_param("~rate", 1)
21     rate = rospy.Rate(hz)
22
23     pub = rospy.Publisher('/test/image', Image, queue_size=1)
24
25     msg = Image()
26     msg.header.stamp = rospy.Time.now()
27     msg.encoding = 'bgr8'
28     msg.height = image.shape[0]
29     msg.width = image.shape[1]
30     msg.step = image.shape[1] * 3
31     msg.data = image.tostring()
32     pub.publish(msg)
33
34     while not rospy.is_shutdown():
35         pub.publish(msg)
36         rate.sleep()