test_cluster_point_indices_to_point_indices.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import unittest
4 
5 import numpy as np
6 
7 from jsk_recognition_msgs.msg import ClusterPointIndices
8 from pcl_msgs.msg import PointIndices
9 import dynamic_reconfigure.client
10 import rospy
11 import rostest
12 
13 
14 class TestClusterPointIndicesToPointIndices(unittest.TestCase):
15 
16  def setUp(self):
17  self.msg = None
18  self.cluster_indices = ((0, 10, 20, 30), (5, 15, 25, 35))
19  self.dynparam = dynamic_reconfigure.client.Client(
20  'cluster_point_indices_to_point_indices')
21  self.pub = rospy.Publisher('~output', ClusterPointIndices,
22  queue_size=1)
23  self.sub = rospy.Subscriber('~input', PointIndices, self.cb)
24 
25  def cb(self, msg):
26  self.msg = msg
27 
28  def test_conversion(self):
29  self.dynparam.update_configuration({'index': 1})
30 
31  cluster_indices_msg = ClusterPointIndices()
32  while self.msg is None:
33  cluster_indices_msg.header.stamp = rospy.Time.now()
34  for indices in self.cluster_indices:
35  cluster_indices_msg.cluster_indices.append(
36  PointIndices(
37  header=cluster_indices_msg.header,
38  indices=indices,
39  )
40  )
41  self.pub.publish(cluster_indices_msg)
42  rospy.sleep(0.1)
43 
44  self.assertTupleEqual(self.msg.indices, self.cluster_indices[1])
45 
46 
47 if __name__ == '__main__':
48  PKG = 'jsk_pcl_ros_utils'
49  ID = 'test_cluster_point_indices_to_point_indices'
50  rospy.init_node(ID)
51  rostest.rosrun(PKG, ID, TestClusterPointIndicesToPointIndices)


jsk_pcl_ros_utils
Author(s): Yohei Kakiuchi
autogenerated on Mon May 3 2021 03:03:15