color_histogram_publisher.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # -*- coding: utf-8 -*-
00003 
00004 import rospy
00005 from jsk_recognition_msgs.msg import ColorHistogram
00006 
00007 class ColorHistogramPublisher():
00008 
00009     def __init__(self):
00010         self.histogram = rospy.get_param('~histogram', [])
00011         self.frame_id = rospy.get_param('~frame_id')
00012         self.pub = rospy.Publisher('~output', ColorHistogram, queue_size=1)
00013 
00014         rate = rospy.get_param('~rate', 1.)
00015         rospy.Timer(rospy.Duration(1. / rate), self.publish)
00016 
00017     def publish(self, event):
00018         histogram_msg = ColorHistogram()
00019         histogram_msg.header.stamp = rospy.Time.now()
00020         histogram_msg.header.frame_id = self.frame_id
00021         histogram_msg.histogram = self.histogram
00022         self.pub.publish(histogram_msg)
00023 
00024 if __name__=='__main__':
00025     rospy.init_node("color_histogram_publisher")
00026     color_histogram_publisher = ColorHistogramPublisher()
00027     rospy.spin()


jsk_pcl_ros
Author(s): Yohei Kakiuchi
autogenerated on Tue Jul 2 2019 19:41:42