object_array_publisher.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import rospy
4 import genpy
5 from jsk_recognition_msgs.msg import Object
6 from jsk_recognition_msgs.msg import ObjectArray
7 
8 
9 class ObjectArrayPublisher(object):
10 
11  def __init__(self):
12  objects = rospy.get_param('~objects')
13  self.msg = ObjectArray()
14  for obj in objects:
15  obj_msg = Object()
16  genpy.message.fill_message_args(obj_msg, obj)
17  self.msg.objects.append(obj_msg)
18 
19  latch = rospy.get_param('~latch', False)
20  self._pub = rospy.Publisher('~output', ObjectArray, queue_size=1,
21  latch=True)
22  self._timer = rospy.Timer(rospy.Duration(1), self._timer_cb,
23  oneshot=latch)
24 
25  def _timer_cb(self, event):
26  self.msg.header.stamp = event.current_real
27  self._pub.publish(self.msg)
28 
29 
30 if __name__ == '__main__':
31  rospy.init_node('object_array_publisher')
33  rospy.spin()


jsk_recognition_msgs
Author(s):
autogenerated on Mon May 3 2021 03:02:56