color_histogram_publisher.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 
4 import rospy
5 from jsk_recognition_msgs.msg import ColorHistogram
6 
8 
9  def __init__(self):
10  self.histogram = rospy.get_param('~histogram', [])
11  self.frame_id = rospy.get_param('~frame_id')
12  self.pub = rospy.Publisher('~output', ColorHistogram, queue_size=1)
13 
14  rate = rospy.get_param('~rate', 1.)
15  rospy.Timer(rospy.Duration(1. / rate), self.publish)
16 
17  def publish(self, event):
18  histogram_msg = ColorHistogram()
19  histogram_msg.header.stamp = rospy.Time.now()
20  histogram_msg.header.frame_id = self.frame_id
21  histogram_msg.histogram = self.histogram
22  self.pub.publish(histogram_msg)
23 
24 if __name__=='__main__':
25  rospy.init_node("color_histogram_publisher")
26  color_histogram_publisher = ColorHistogramPublisher()
27  rospy.spin()


jsk_pcl_ros
Author(s): Yohei Kakiuchi
autogenerated on Mon May 3 2021 03:03:46