test_point_indices_to_cluster_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 rospy
10 import rostest
11 
12 
13 class TestPointIndicesToClusterPointIndices(unittest.TestCase):
14 
15  def setUp(self):
16  self.msg = None
17  self.indices = (0, 10, 20, 30)
18  self.pub = rospy.Publisher('~output', PointIndices, queue_size=1)
19  self.sub = rospy.Subscriber('~input', ClusterPointIndices, self.cb)
20 
21  def cb(self, msg):
22  self.msg = msg
23 
24  def test_conversion(self):
25  indices_msg = PointIndices()
26  while self.msg is None:
27  indices_msg.header.stamp = rospy.Time.now()
28  indices_msg.indices = self.indices
29  self.pub.publish(indices_msg)
30  rospy.sleep(0.1)
31 
32  self.assertEqual(len(self.msg.cluster_indices), 1)
33  self.assertTupleEqual(self.msg.cluster_indices[0].indices,
34  self.indices)
35 
36 
37 if __name__ == "__main__":
38  PKG = 'jsk_pcl_ros_utils'
39  ID = 'test_point_indices_to_cluster_point_indices'
40  rospy.init_node(ID)
41  rostest.rosrun(PKG, ID, TestPointIndicesToClusterPointIndices)


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