7 from threading
import Event
8 from unittest
import TestCase
10 import dynamic_reconfigure.client
11 from jsk_recognition_msgs.msg
import PolygonArray, ModelCoefficientsArray
12 from geometry_msgs.msg
import PolygonStamped
13 from pcl_msgs.msg
import ModelCoefficients
15 TEST_NODE =
"/polygon_array_unwrapper" 19 self.
client = dynamic_reconfigure.client.Client(TEST_NODE, timeout=30)
20 self.
pub_polygon = rospy.Publisher(TEST_NODE +
"/input_polygons",
21 PolygonArray, queue_size=1)
23 ModelCoefficientsArray, queue_size=1)
35 self.polygon_msg_callback_event.clear()
36 self.coeff_msg_callback_event.clear()
38 self.
sub_polygon = rospy.Subscriber(TEST_NODE +
"/output_polygon",
45 self.sub_polygon.unregister()
46 self.sub_coefficients.unregister()
49 self.polygon_msg_callback_event.set()
52 self.coeff_msg_callback_event.set()
55 pmsg.header.stamp = rospy.Time.now()
56 cmsg = ModelCoefficientsArray()
57 cmsg.header.stamp = pmsg.header.stamp
59 pmsg.polygons.append(PolygonStamped())
60 pmsg.polygons[i].header.stamp = pmsg.header.stamp
61 pmsg.polygons[i].header.frame_id = str(i)
62 cmsg.coefficients.append(ModelCoefficients())
63 cmsg.coefficients[i].header.stamp = cmsg.header.stamp
64 cmsg.coefficients[i].header.frame_id = str(i)
65 pmsg.likelihood = [1.0,2.0,3.0,4.0,5.0,4.0,3.0,2.0,1.0,0.0]
66 self.pub_polygon.publish(pmsg)
67 self.pub_coefficients.publish(cmsg)
72 self.client.update_configuration({
74 "use_likelihood":
False 80 self.assertTrue(self.
coeff_msg is not None)
81 self.assertEqual(self.polygon_msg.header.frame_id, str(0))
82 self.assertEqual(self.coeff_msg.header.frame_id, str(0))
84 self.client.update_configuration({
86 "use_likelihood":
False 92 self.assertTrue(self.
coeff_msg is not None)
93 self.assertEqual(self.polygon_msg.header.frame_id, str(7))
94 self.assertEqual(self.coeff_msg.header.frame_id, str(7))
96 self.client.update_configuration({
98 "use_likelihood":
True 104 self.assertTrue(self.
coeff_msg is not None)
105 self.assertEqual(self.polygon_msg.header.frame_id, str(4))
106 self.assertEqual(self.coeff_msg.header.frame_id, str(4))
108 if __name__ ==
'__main__':
110 rospy.init_node(
"polygon_array_unwrapper_test")
111 rostest.rosrun(
"jsk_pcl_ros_utils",
"polygon_array_unwrapper_test", TestPolygonArrayUnwrapper)
def publishPolygons(self, event=None)
def testUnwrapIndex(self)
def testUnwrapLikelihood(self)
def polygonMsgCallback(self, msg)
polygon_msg_callback_event
def coeffMsgCallback(self, msg)