test_point_indices_to_cluster_point_indices.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 import unittest
00004 
00005 import numpy as np
00006 
00007 from jsk_recognition_msgs.msg import ClusterPointIndices
00008 from pcl_msgs.msg import PointIndices
00009 import rospy
00010 import rostest
00011 
00012 
00013 class TestPointIndicesToClusterPointIndices(unittest.TestCase):
00014 
00015     def setUp(self):
00016         self.msg = None
00017         self.indices = (0, 10, 20, 30)
00018         self.pub = rospy.Publisher('~output', PointIndices, queue_size=1)
00019         self.sub = rospy.Subscriber('~input', ClusterPointIndices, self.cb)
00020 
00021     def cb(self, msg):
00022         self.msg = msg
00023 
00024     def test_conversion(self):
00025         indices_msg = PointIndices()
00026         while self.msg is None:
00027             indices_msg.header.stamp = rospy.Time.now()
00028             indices_msg.indices = self.indices
00029             self.pub.publish(indices_msg)
00030             rospy.sleep(0.1)
00031 
00032         self.assertEqual(len(self.msg.cluster_indices), 1)
00033         self.assertTupleEqual(self.msg.cluster_indices[0].indices,
00034                               self.indices)
00035 
00036 
00037 if __name__ == "__main__":
00038     PKG = 'jsk_pcl_ros_utils'
00039     ID = 'test_point_indices_to_cluster_point_indices'
00040     rospy.init_node(ID)
00041     rostest.rosrun(PKG, ID, TestPointIndicesToClusterPointIndices)


jsk_pcl_ros_utils
Author(s): Yohei Kakiuchi
autogenerated on Tue Jul 2 2019 19:40:52